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
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
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
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
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] ==>
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
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
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
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:
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)
10 matches
Mail list logo