Counters and totals in a Python loop
Set count = 0 before a loop, then use count += 1 inside it to add 1 each repeat. Use total += value to build a running total.
Understanding Counters and totals in a Python loop in VCE Software Development U3O1
What it does: The line count = 0 sits before the loop and gives the counter a starting value. Inside the loop, count += 1 adds one each repeat. total += score adds score to what is already in total. total = score throws away the old total. total grows each repeat: 0 + 2 + 5 + 3 = 10. Using = instead of += would leave only 3. += is a shortcut. It takes the current total, adds value, and stores the answer back in total. The + must come before the =. Writing =+ replaces the total with the new value, so the running total is lost.
Common mistakes: Python cares about capital letters. The variable is called count, not Count, so Count causes a NameError. It should be print(count). A running total must start at 0 before the loop. Starting at 1 makes the answer 1 too big. It should be total = 0.
Free printable worksheet with full answer key — or add this module to a class and your students practise it interactively.
This module's key terms are also in a printable crossword (Modules 10–47) and word search (Modules 10–71).
Take this worksheet further — free with Cloodit
Each concept is reinforced from every angle — learned, then applied, then tested.
Cloodit turns curriculum-aligned coding content into journeys students work through one biome at a time.
Over 100 of them, across seven natural biomes.
Turns their work into revision material ready for Flash Cards and Exam study.
Live, competitive practice for the start of the lesson or a teacher-led lesson finisher.
Honour your top performers, or encourage a student who's trying hard — ready to print in seconds.
Quick Questions
Match the Pairs
Key Term
count += 1Fill in the Blanks
Spot the Error
Student with a class code? Join your class →