Re: What is not working with my "map" usage?

2018-09-22 Thread ROGER GRAYDON CHRISTMAN
On Sat, Sep 22, 2018, Victor (vhnguy...@yahoo.com) wrote Let me use a different input args and display them below. Basically, I am hoping to add up all elements of each nested list. So at first it should start with [1,11,111] ==> 1+11+111 = 123. But instead, it appears to take the 1st element

Re: What is not working with my "map" usage?

2018-09-22 Thread Victor via Python-list
On Saturday, September 22, 2018 at 12:20:08 PM UTC-7, Thomas Jollans wrote: > On 22/09/2018 20:18, Victor via Python-list wrote: > > On Saturday, September 22, 2018 at 6:22:32 AM UTC-7, Peter Otten wrote: > >> Victor via Python-list wrote: > >> > >>> Let me use a different input args and display

Re: What is not working with my "map" usage?

2018-09-22 Thread Thomas Jollans
On 22/09/2018 20:18, Victor via Python-list wrote: On Saturday, September 22, 2018 at 6:22:32 AM UTC-7, Peter Otten wrote: Victor via Python-list wrote: Let me use a different input args and display them below. Basically, I am hoping to add up all elements of each nested list. So at first

Re: What is not working with my "map" usage?

2018-09-22 Thread Peter Otten
Victor via Python-list wrote: > On Saturday, September 22, 2018 at 6:22:32 AM UTC-7, Peter Otten wrote: >> Victor via Python-list wrote: >> >> > Let me use a different input args and display them below. Basically, I >> > am >> > hoping to add up all elements of each nested list. So at first it

Re: What is not working with my "map" usage?

2018-09-22 Thread Victor via Python-list
On Saturday, September 22, 2018 at 6:22:32 AM UTC-7, Peter Otten wrote: > Victor via Python-list wrote: > > > Let me use a different input args and display them below. Basically, I am > > hoping to add up all elements of each nested list. So at first it should > > start with [1,11,111] ==>

Re: What is not working with my "map" usage?

2018-09-22 Thread Peter Otten
Victor via Python-list wrote: > Let me use a different input args and display them below. Basically, I am > hoping to add up all elements of each nested list. So at first it should > start with [1,11,111] ==> 1+11+111 = 123. But instead, it appears to take > the 1st element from each nested

Re: What is not working with my "map" usage?

2018-09-22 Thread Victor via Python-list
Let me use a different input args and display them below. Basically, I am hoping to add up all elements of each nested list. So at first it should start with [1,11,111] ==> 1+11+111 = 123. But instead, it appears to take the 1st element from each nested list to add up [1,2,3] = 6. How

Re: What is not working with my "map" usage?

2018-09-21 Thread Thomas Jollans
On 21/09/2018 23:29, Viet Nguyen via Python-list wrote: 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

Re: What is not working with my "map" usage?

2018-09-21 Thread Brian Oney via Python-list
Hi Viet, map applies the function to each of the elements of the list you provide. It would be roughly equivalent to: [add_all_elements(x) for x in alist] It may help you to consider the term and function "map" from the view of linear algebra. Apparently it's a common term:

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)