Sum of multiple list of lists index wise

Viewed 4473

Consider I have a list of lists as:

[[5, 10, 30, 24, 100], [1, 9, 25, 49, 81]]
[[15, 10, 10, 16, 70], [10, 1, 25, 11, 19]]
[[34, 20, 10, 10, 30], [9, 20, 25, 30, 80]]

Now I want the sum of all indexes of first list's index wise and then the 2nd list 5+15+34=54 10+10+20=40 and so on as:

[54,40,50, 50,200], [20,30,75,90,180]

I tried:

for res in results:     
    print [sum(j) for j in zip(*res)] 

Here results is the list of lists. But it gives sum of each list item as:

[6,19,55,73,181]
[25,11,35,27,89]
[43,40,35,40,110]
3 Answers
Related