Error Handling – try/except basics
A try/except block runs code and catches errors so the program does not crash
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 journey and assign it to your class.
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
Create a free class, add this module to a journey, and track who's stuck.
Create a free teacher account →No credit card. No setup fee. Make a class and invite students in under three minutes.
Practice this topic interactively, track progress, and unlock badges.
Start Learning Free →