How to Read Error Messages: A Guide for Kids and Parents

ยท 3 min read ยท By the Tiny Coderz team

A child runs their program and the screen fills with red text. Their face falls. "It's broken. I'm bad at this."

It is worth changing that story early. An error message is not a scolding. It is the computer doing its best to tell you what went wrong and where. Learning to read these messages is one of the most valuable skills in programming, and it is much easier than it looks.

The three parts of a Python error

Here is a typical error:

print("Hello"

Python replies with something like:

File "main.py", line 1
    print("Hello"
                 ^
SyntaxError: '(' was never closed

Every error has the same three clues:

  1. Where: the file and the line number. Here, line 1.
  2. A pointer: the little ^ often shows the spot Python got confused.
  3. What kind and why: SyntaxError is the type, and the sentence after it explains the problem in words.

Teach your child to read the last line first, then look at the line number.

The most common error types

You do not need to memorise these, but they become familiar friends:

  • SyntaxError: the code is written in a way Python cannot understand. Usually a missing bracket, quote or colon.
  • NameError: Python met a word it does not know, often a misspelled variable, or one used before it was created.
  • IndentationError: the spaces at the start of a line are wrong.
  • TypeError: you tried something that does not mix, like adding a number to text.
  • IndexError: you asked a list for an item that is not there. See Python lists for kids.
  • ZeroDivisionError: you divided by zero, which no computer can do.

A simple routine

Give your child this little routine to follow when red text appears:

  1. Breathe. Errors are normal. Professionals see them daily.
  2. Read the last line. What type is it, and what does it say?
  3. Find the line number. Look at that line, and the line just above it.
  4. Guess the fix. Say it out loud: "I think I forgot a colon."
  5. Change one thing, then run again.

Changing one thing at a time matters. If you change five things and it works, you will not know which one fixed it.

What parents can do

You do not need to understand the code. Try these questions instead:

  • "What does the last line say, in your own words?"
  • "Which line is it pointing to?"
  • "What do you think it wants?"

Resist the urge to grab the keyboard. Our article on helping your child when they are stuck goes deeper on asking questions rather than giving answers.

Reframing mistakes

Every error message your child fixes builds confidence. When they solve one alone, celebrate it, as we describe in praising mistakes and the bug mindset. And when an error is truly baffling, searching the exact error text, or asking a patient helper, is a normal professional move, not cheating.

For a full process to follow when code misbehaves without any red text at all, read debugging for kids: how to find bugs.

Try Python Fundamentals with your child

Every lesson in Python Fundamentals opens with an animated explanation, then a short practice. You can read a full sample lesson with no account.

Keep reading