Running totals and counters
Not met yet
A running total starts at 0 before the loop and grows on every pass: total = total + amount. A counter is a running total that grows by 1. Both are set before the loop. Set inside it, they go back to 0 every pass.
Try it
main.pyOutput
Press Run and what your program prints shows up here.
Easy to get wrong
- Puts total = 0 inside the loop, or thinks it does no harm there, so the total resets every pass.
- Thinks a total can be added to before it has been given a starting value.