Lists can store the intermediate states of a calculation. Start with an empty result and append one new value per input.
A scoreboard remembers the best throw seen so far after each turn.
best = 0
history = []
for distance in [3, 2, 5]:
best = max(best, distance)
history.append(best)
print(history) # [3, 3, 5]The second throw leaves the best score at 3. Appending it still records a snapshot for that turn. A balance can change in either direction.
Complete running_totals(changes). Start the balance at zero and return a new list of balances after each change. Negative changes are withdrawals. Preserve the input.
running_totals([4, -2, 3]) # [4, 2, 5]