Index summation in Python

how to do a sum in the list, for example [3,0,1,-2,] return [3,3,4,2], adding index by index

What I have tried:

list = [3,0,1,-2]
total = 0
for i in list:
total = total + i


This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.