time_interval = [4, 6, 12]
I want to sum up the numbers like [4, 4+6, 4+6+12] in order to get the list t = [4, 10, 22].>
[4, 4+6, 4+6+12]
t = [4, 10, 22]
values = [4, 6, 12] total = 0 sums = [] for v in values: total = total + v sums.append(total) print 'Values: ', values print 'Sums: ', sums
Running this code gives
Values: [4, 6, 12] Sums: [4, 10, 22]