Hi,
I want to add up all of the list elements. But when I use the "map" function,
it didn't seem to work as I expect. Could someone point out how "map" can be
applied here then?
def add_all_elements (*args):
total = 0
for i in args:
print(type(i))
print("i = %s" % i)
t.__next__()
> (4, 1)
> >>> aList.__next__()
> (5, 8)
> >>> aList.__next__()
> Traceback (most recent call last):
> File "", line 1, in
> StopIteration
> >>>
>
>
> -Original Message-
> From: Python-list
> [mailt
On Thursday, September 6, 2018 at 10:34:19 AM UTC-7, Chris Angelico wrote:
> On Fri, Sep 7, 2018 at 3:26 AM, Viet Nguyen via Python-list
> wrote:
> >>>> numList
> > [2, 7, 22, 30, 1, 8]
> >
> >>>> aList = enumerate(numList)
> >
> >>&g
>>> numList
[2, 7, 22, 30, 1, 8]
>>> aList = enumerate(numList)
>>> for i,j in aList:print(i,j)
0 2
1 7
2 22
3 30
4 1
5 8
>>> for i,j in aList:print(i,j)
>>>
--
https://mail.python.org/mailman/listinfo/python-list