Summing a tuple in a list, in python -
i know there must quick way this, can't seem find it. need find way add items in tuple. hoping mytuple.sum.
i have list of tuples mylist= [(1,3,5,3),(1,5,5,5),....,(1,3,2,1),(1,1,1,2)]
and need able call on mylist[0].sum
thanks!
it's hard tell want, it's 1 of
sum(mylist[0])
or
sum(sum(x) x in mylist)
or
map(sum, mylist)
Comments
Post a Comment