-1

I have the following list:

myList = [5,15,23,45,2,43]

I want to create a running total in a new list, so it would look like:

newList = [20,43,88,90,133]

How would I do this?

Sophie
  • 11
  • 4

1 Answers1

1

try this:

newList = [sum(myList[:i+1]) for i in range(len(myList))][1:]
Zito Relova
  • 1,041
  • 2
  • 13
  • 32