Lesson 3.8
An accumulator collects the sum of values. It's like a counter, but it adds the next number instead of one:
total = 0
for i in range(1, 101):
total += i
print(total)
The program prints 5050 — the sum of the numbers from 1 to 100.
The difference from a counter is short: a counter does count += 1, an accumulator does total += i.
The mistake total = i replaces the sum with the last number every time instead of
collecting it.
Print the sum of the numbers from start to stop inclusive. start and stop
are set by the check. Don't use sum() — collect the total with a loop.
An accumulator is a variable too, but you add to it.
Start at zero, add each number in the loop, and print the sum after the loop.
+ 1 instead of += number is the most common mistake.