Infinite loops and how to stop them
A while loop whose condition never becomes False, often because the loop variable is never updated. Stop it with the Stop button, or fix it by changing the variable inside the loop.
Understanding Infinite loops and how to stop them in ACARA Digital Technologies Years 7–8
What it does: When the if condition is True, break jumps out of the loop immediately, so the loop stops even though while True never becomes False. An infinite loop will never finish on its own. The Stop button ends the running program. break leaves the loop straight away. Printing a value does not stop the loop. Changing the variable is not enough. It must change in a direction that makes the condition False. Use x = x - 1 to count down. Forgetting to update the loop variable is the most common cause of an infinite loop.
Common mistakes: count goes down, so count <= 5 is always True and the loop never ends. It should be count = count + 1 so count grows towards 5. A while line must end with a colon. It should be while True: and the break inside is what stops this loop.
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 522–560) and word search (Modules 522–580).
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
infinite loopFill in the Blanks
Spot the Error
Student with a class code? Join your class →