break to exit a loop
A keyword that stops the loop it is in straight away. The program then carries on with the first line after the loop. It is often used inside while True to exit when a condition is met.
Understanding break to exit a loop in Years 7–8 Creating Digital Solutions
What it does: An if statement checks the condition, and break inside it ends the loop as soon as the condition is met. break leaves the loop at once, so the program continues with the print() line, which is outside the loop. break jumps out of the loop. It does not go back to the top of the loop. break is inside the if block, so it must be indented. Without indentation Python gives an IndentationError. Python only understands break. Spelling it brake would cause a NameError.
Common mistakes: True must start with a capital letter in Python. Lowercase true is not a keyword, so Python gives a NameError. It should be while True:. The while line is missing a colon at the end. Python needs the colon before the indented loop body. It should be while True:.
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 50–125) and word search (Modules 3–125).
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
breakFill in the Blanks
Spot the Error
Student with a class code? Join your class →