▶ Sign up free for the video, slides & prompts
The lesson below is open to all. Enter your email once to unlock every video, slide deck, prompt and code example on this device.
Checking…
Reading error messages
What Python is telling you when it complains, and how to fix it.
🎬 Video version coming soon — read it now
Errors are not failures. They're Python telling you exactly what went wrong and where. Professional developers see errors all day long. The skill is reading them calmly.
Anatomy of an error
🔒 Code example: sign up free (above) to unlock it.
🔒 Code example: sign up free (above) to unlock it.
Read the last line first. It tells you the error type (NameError) and the reason ('prise' is not defined). The arrow shows the line. Here it's a typo: prise should be price.
The five errors you'll meet most
- SyntaxError: Python can't read the code. Look for a missing quote, bracket or colon.
- NameError: you used a name Python doesn't know. Usually a typo, or a cell you forgot to run.
- TypeError: you mixed types the wrong way, like
"Age: " + 21. - ValueError: the type was right but the value wasn't, like
int("abc"). - IndentationError: the spaces at the start of a line are wrong. You'll meet this one with
ifand loops.
A calm debugging routine
- Read the last line of the error.
- Go to the line the arrow points to. Look at it and the line above, because a missing bracket often breaks the next line.
- Check spelling, quotes, brackets and types.
- Change one thing and run again.
- Still stuck? Copy the last line of the error into a search engine or an AI tutor. That's the next lesson.
Tip: Make errors on purpose. Delete a quote, misspell print, add a number to a string. Once you've seen each error once, it stops being scary.
In one line
Read the last line of the error first: it names the problem, and the arrow shows where it happened.
Saved on this device. Sign in to keep progress everywhere.
Share with a friend