What is not working with my "map" usage?

2018-09-21 Thread Viet Nguyen via Python-list
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)

Re: Why emumerated list is empty on 2nd round of print?

2018-09-06 Thread Viet Nguyen via Python-list
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

Re: Why emumerated list is empty on 2nd round of print?

2018-09-06 Thread Viet Nguyen via Python-list
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

Why emumerated list is empty on 2nd round of print?

2018-09-06 Thread Viet Nguyen via Python-list
>>> 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