The big ideaAn error message is a clue. Read the last line, find the line, fix it.
How it works
An error message is a clue from the computer. It says what happened and where. It is not a telling-off, and nothing is broken.
Read the last line first. It names the kind of problem.
Just above it is a line number, which says where the computer got stuck.
Look closely at that line, change one thing so you know what helped, and run it again.
Five kinds of error and what they mean.
Example 1: A NameError
Mina reads the last line: NameError, the name cont is not defined.
The line number says line three, so she looks there.
On line three she typed cont, but she meant count.
She adds the missing letter, runs it again, and Bo waves.
Example 2: A SyntaxError
Teo's for line is missing its colon.
The last line says SyntaxError, and it says a colon was expected.
Syntax is how a line is written, so a piece is missing.
Teo adds the colon and runs it again.
Example 3: An IndexError
Mina has a list of three snacks and asks for box three.
The last line says IndexError: list index out of range.
Boxes count from zero, so the boxes are 0, 1 and 2, and the last box is two.
One small change to box two fixes it.
Example 4: The plan
An error message pops up.
Read the last line, find the line number, and look at that line.
Change one thing, and run it again.
It is fixed, or you get a new clue.
Words to know
error message
A clue from the computer about what happened and where.
line number
Says where the computer got stuck.
NameError
The computer cannot find a name, often a typo.
SyntaxError
A line is written with a piece missing or extra.
IndexError
A list has no box with that number.
Watch out
An error message is not a telling-off, and it does not mean you broke anything.
Read the last line first, not the top of the message.
Change one thing at a time, so you know what helped.
One missing letter can be the whole problem, because a computer cannot guess.
Try it
Where do you read first in an error message?
A list has three boxes and the code asks for box three. Which error is it?
What does a NameError often mean?
What should you do after you change one thing?
A for line is missing its colon. Which error is it?
Answers: 1. The last line · 2. IndexError · 3. A typo in a name · 4. Run it again · 5. SyntaxError
Try at homeAsk a grown-up to write a short sentence with one tiny slip, like a missing letter or a missing full stop. Read it slowly, from the last word back to the first, to find the slip, just as a coder does with an error message.
For grown-upsWhen your child meets an error on a real screen, ask them to read the last line aloud to you and then say the line number before touching the keyboard. It builds the habit of treating it as a clue.
Open these notes on screenScan the code, or go to tutorpip.com.