SyntaxFix
Write A Post
Hire A Developer
Questions
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]