Error Handling – try/except basics
A try/except block runs code and catches errors so the program does not crash
Understanding Error Handling – try/except basics in Python
What it does: Naming the exception type catches only that specific kind of error. try/except intercepts errors and lets you handle them gracefully. Put risky code inside try — if it fails, except handles it. If try succeeds, except is completely skipped. int('abc') causes a ValueError — except catches it and prints 'Oops'. 5 + 3 works fine — no error, so except is skipped. 'hello' can't be converted to an integer — that's a ValueError. except always needs a matching try block before it.
Common mistakes: Missing colon after try. Missing colon after except.
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 21–30) and word search (Modules 21–40).
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
tryFill in the Blanks
Spot the Error
Student with a class code? Join your class →