promptdojo_

try/except — the patterns AI misuses — step 6 of 8

Claude shipped this and it "worked" for weeks — until someone noticed every call returned fallback, even for perfectly good input like "42". Two bugs conspire: line 4 has a typo (numbre), and the bare except: on line 5 swallows the NameError the typo raises, so the typo never surfaced as a crash.

Fix both lines: correct the typo to number, and replace the bare except: with one that catches only ValueError. Expected output:

42
fallback
The break is on lines 4, 5 — but read the whole snippet first.

full-screen editor opens — close anytime to keep reading.