IndentationError and missing colons
Python errors when a block's lines are not indented consistently, or when the if, for, while or def line that opens the block is missing its colon.
Understanding IndentationError and missing colons in ACARA Digital Technologies Years 7–8
What it does: Both lines in the while body are indented by exactly 4 spaces, so Python treats them as one block and doesn't raise an IndentationError. An if line must end with a colon. Without it Python shows a SyntaxError because it cannot tell where the block starts. Mixing tabs and spaces can look the same on screen but confuses Python. Pick one style, usually 4 spaces, and stick to it.
Common mistakes: The if line opens a block, so it must end with a colon. Without it Python raises a syntax error. It should be: if score > 5:. The if line opens a block but has no colon, so the indented line below it has nothing to belong to. It should be: if age < 13:.
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 482–519) and word search (Modules 420–519).
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
IndentationErrorFill in the Blanks
Spot the Error
Student with a class code? Join your class →