Two sums from one list
I'd like to get the sums for two different values in a list. For example:
sample = [(1,3), (4,5), (8,2)]
I'd like the output to be
13, 10
I could do it in a couple of different ways. Here's how I have it currently:
t1 = 0
t2 = 0
for item1, item2 in sample:
t1 += item1
t2 += item2
What would be a more Pythonic way to solve this?
No comments:
Post a Comment