Reading error messages without panic
An error message isn’t a verdict on whether you can code. It’s Python being unusually precise about exactly what it doesn’t understand — closer to a colleague flagging the one clause in a contract that doesn’t parse than a judgment on the whole document. Once you know the pattern, most errors take seconds to read.
Read from the bottom up
Python’s error messages (called tracebacks) can look long and alarming, but the part that matters most is almost always the very last line: the error type, and a short description. Everything above it is just the trail of calls that led there. Start at the bottom, then look upward only if you need more context.
Example: NameError
client_name = "Meridian Health Trust"
print(cilent_name)
Run this and Python stops with NameError: name 'cilent_name' is not defined. That’s it being precise: you asked it to print something called cilent_name, and nothing by that name exists — because it’s a typo of client_name. Python never guesses what you meant; it tells you plainly what it doesn’t recognise.
Example: TypeError
hours = "12"
rate = 250
print(hours + rate)
This one raises TypeError: can only concatenate str (not "int") to str. hours is text (a string, because it’s in quotes), not a number — often the case when a value has come from a form or a spreadsheet import. Python won’t guess whether "12" + 250 should mean “add the numbers” or “join the text,” so it stops and asks you to be explicit: int(hours) + rate if you meant maths.
Example: IndentationError
if rate > 100:
print("Premium rate")
IndentationError: expected an indented block means exactly what it says: Python uses indentation to know which lines belong inside the if, and the print line here has none. Indent it, and the error disappears — Python was never confused about the logic, only about which lines belonged where.
The habit worth building
Read the last line first. Find the line number it points to. Trust that the message is telling you the actual problem, not being deliberately obscure. Almost every error you’ll meet as a beginner is one of a small handful of types, and each one gets boring — in a good way — the second time you see it.