Running Balance

Python FundamentalsMedium+10 XP+10

Running Balance

A piggy bank app shows the balance after every deposit.

Task: write running_totals(deposits) that returns a new list where each value is the total of all deposits up to and including that one.

  • If deposits is empty, return an empty list.

Examples

deposits = [5, 3, 10, 2]
returns [5, 8, 18, 20]
deposits = [1, 1, 1]
returns [1, 2, 3]

Hints

Solve it to unlock the solution

Once your code passes every test, a reference solution shows up here so you can compare it with yours.

solution.py
CtrlEnterto run