Twelve lines of red text
The nightly sales report did not arrive. Your manager forwards you the error: twelve lines of red text.
It looks frightening. But most of those lines are a route map, and one line holds the answer.
Reading errors calmly is a skill every technical job uses daily.
By the end of this lesson
Note
I can read an error message and find the fix.
Key words
| Word | What it means | Example |
|---|---|---|
| Error message | text a program prints when it cannot go on | |
| Traceback | the list of steps Python took before the error | |
| Exception | the named kind of error | TypeError |
| Documentation | the official guide to a tool or language | |
| SSH | a safe way to open a terminal on another computer |
The cells students fill in are left blank in this preview.
Read a traceback from the bottom
In Python, the last line of a traceback names the exception and says what went wrong.
The line just above it gives the file and the line number where it happened.
The lines higher up show the route the program took to get there. Read them only if the bottom is not enough.
Make an error and read it
# The report prints how many orders came in today.
orders_today = 12
# Run this. Read the LAST line of the error first.
message = "Orders today: " + orders_today
print(message)
# Fix it: turn the number into text with str(orders_today).
Worked example: errors you will meet
| Last line starts with | What it usually means |
|---|---|
| NameError | A name is misspelt or not made yet |
| TypeError | Two kinds of value were mixed, such as text and a number |
| KeyError | A dictionary has no such key |
| FileNotFoundError | The path is wrong, or you are in the wrong folder |
| ZeroDivisionError | Something was divided by 0 |
| ModuleNotFoundError | A library is not installed |
The cells students fill in are left blank in this preview.
A common mistake
Warning
Many people think the first red line is the cause, so they fix the wrong place. In a Python traceback the cause is at the bottom. Read the last line, then the line number just above it.
Search with the exact message
Copy the exception and its message into a search. Leave out your own file names and numbers.
Look at the official documentation first. It is written by the people who made the tool.
Check that the page matches your version. An answer for an old version can be wrong for yours.
A good question gets a quick answer
If you are stuck after twenty minutes, ask a colleague. Say what you were trying to do and what you expected.
Then say what happened, with the full error message, and what you have tried.
Never paste a password, a key or a customer's details into a question.
Worked example: two ways to ask
| A poor question | A good question |
|---|---|
| The report is broken. | The nightly report stops with KeyError: price on line 14. |
| It does not work. | I expected a total. I got the error below. |
| Can you fix it? | I checked the JSON, and some orders have no price. Should they? |
The cells students fill in are left blank in this preview.
SSH takes you to the server
Often the error happened on a server, not on your laptop. SSH opens a terminal on that server over the network.
You type ssh and a user name and host, such as ssh [email protected]. Then the commands you know work there: cd, ls and grep.
Finding the error on a server
$ ssh [email protected]
sam@reports:~$ cd /var/log/reports
sam@reports:/var/log/reports$ grep ERROR nightly.log
2026-10-21 02:00:14 ERROR KeyError: 'price'
sam@reports:/var/log/reports$ exit
logout
Connection to reports.shop.example closed.