Home › Python Error Explainer

Python Error Explainer

6 deep-dive explainersEvery page links to interactive fixes

Pick the error in your traceback

Each explainer below is a focused deep dive into one exception: what the message literally means, a real runnable example with its full traceback, the specific causes, a debugging routine, and free PyDebug problems where you repair that exact error in the browser.

NameError

name 'x' is not defined — typos, definition order, and scope, decoded from the message itself.

TypeError

str + int, 'not callable', 'not iterable' — one exception, five famous wordings, each decoded.

IndexError

list index out of range — why len(list) is never a valid index, and the four loop shapes that cause it.

KeyError

the missing dictionary key — exact-match rules, get() vs [] vs setdefault, nested-dict traps.

ValueError

invalid literal for int() — right type, impossible value, and the unpacking variants.

ZeroDivisionError

division by zero — almost always a missing-data bug wearing an arithmetic costume.

How to read any Python traceback

Read it bottom-up: the last line names the exception and its message; the lines above show the call chain that led there, with the deepest (most useful) frame last. Two facts direct everything else: the exception type tells you which rule was broken, and the message payload — the quoted name, key, index, or value — tells you which piece of your data broke it.

Errors not covered above — AttributeError, ImportError, IndentationError, RecursionError and more — live in the complete Python errors guide. For the searching-and-narrowing method itself, see the Python debugging guide.