Loading...
Loading...
Loading...
A bank account starts at 0. Then n transactions happen in order, where a negative number is a withdrawal. Print the balance after each transaction.
Example
Input
4 500 -200 -400 300
Output
500 300 -100 200
The balance goes 500, 300, -100, 200.
Try the problem first. Open one hint at a time.
The balance after a transaction is the balance before it plus the transaction.
itertools.accumulate gives the running total directly.
Write your Python code, run it on the examples and submit it to hidden tests.
Solve in the editor