Problem 138542 · easy · Phase 01 Prerequisites & Setup

Running Balance

lists · accumulation · append

A bank account starts at 0. Write running_balance(transactions) where positive values are deposits and negative values are withdrawals. Return a new list with the balance after each transaction.

Examples

Input:  transactions = [100, -30, 50]
Output: [100, 70, 120]

Input:  transactions = []
Output: []

Constraints

  • 0 <= len(transactions) <= 5000

Goals

  • Keep a running total while looping
  • Record the total after each step in a new list
Starting Python…