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

Popular posts from this blog

javascript - Karma not able to start PhantomJS on Windows - Error: spawn UNKNOWN -

c# - Display ASPX Popup control in RowDeleteing Event (ASPX Gridview) -

Nuget pack csproj using nuspec -