What: A plain-English guide to the 3 Python error messages beginners see most.
Who: Kids aged 7–14 and the parents who help them code.
Why: Errors stop most first programs, and they’re easy to fix once you can read them.
When: Every time a program won’t run, starting with your first print() line.
How: Read the message, find the line, match the pattern, fix, and run again.
Your child types a short program, presses Run, and a wall of red text appears. Most kids think they’ve broken something. Most parents don’t know where to look either.
Here’s the good news: Python error messages are clues, not punishments. This guide shows your child how to read each one, with real examples tested on Python 3.13. If your child is still deciding between block coding and typing code, start with our guide to block-based vs text-based coding for kids.

A Python error message is Python’s way of telling you exactly what it couldn’t understand. It names the problem, points to the line, and often suggests a fix.
Think of Python as a very literal reader. If a sentence is missing a full stop, a person still gets the meaning. Python stops and asks you to fix it.
Python error messages fall into 2 groups:
In Scratch, blocks only snap together when they fit, so kids rarely see errors. Typed code gives your child more freedom and more ways to slip. That’s why reading errors is the first real skill in text-based coding. Our Scratch to Python guide explains how that move works, and our debugging in Scratch guide shows where the debugging habit starts.

Read the last line first. It names the error type and says what went wrong.
Here’s a real example from a program with a missing colon:
age = 10
if age > 9
print("Big kid!")
File "main.py", line 2
if age > 9
^
SyntaxError: expected ':'
Every error message has 4 parts:
| Part | What it tells you | In the example |
|---|---|---|
| File and line number | Where Python got stuck | line 2 |
| Your code, repeated | The exact line to check | if age > 9 |
The caret ^ or ^^^ | The spot Python flagged | Right after 9 |
| Error type and reason | What kind of mistake it is | SyntaxError: expected ':' |
When a program runs for a while before failing, Python also prints a traceback. That’s a list of the steps it took before the crash. Your child only needs the last 2 lines at first.
Quotable tip: Python’s error message tells you the line, the spot, and the reason. Read all three before you change anything.
Python 3.10 and newer give friendlier messages, including “Did you mean” hints. Older versions often say only invalid syntax. Check which version your child uses. The official Python 3.10 release notes explain when the friendlier messages arrived.

A SyntaxError means your code breaks Python’s grammar rules. Python can’t read the line, so it never runs the program.
It’s like a sentence with a missing word. The message usually appears on the line with the problem or the line just after it.
age = 10
if age > 9
print("Big kid!")
Python says SyntaxError: expected ':'. Add a colon at the end of the if line. The same rule applies to for, while, def, and else.
print("Hello, coder!)
Python says SyntaxError: unterminated string literal (detected at line 1). The opening quote never found its partner. Add the closing " before the bracket.
print("Total:", (2 + 3)
x = 1
Python says SyntaxError: '(' was never closed. Count your brackets. Every ( needs a ).
name = input("Name? ")
if name = "Mia":
print("Hi")
Python says SyntaxError: invalid syntax. Maybe you meant '==' or ':=' instead of '='?. Use = to store a value. Use == to compare two values.
print("Score:" score)
Python says SyntaxError: invalid syntax. Perhaps you forgot a comma? Put a comma between the two items.

An IndentationError means a line has the wrong amount of space at the start. Python uses indentation to know which lines belong together.
Picture a lunch line. Everyone inside a group stands the same distance from the wall. If one person steps out of place, the group gets confused.
age = 10
if age > 9:
print("Big kid!")
Python says IndentationError: expected an indented block after 'if' statement on line 2. Move the print line 4 spaces to the right.
def greet():
name = "Mia"
print(name)
Python says IndentationError: unexpected indent. Line 3 has extra spaces. Line it up with the line above.
for i in range(3):
print(i)
print("done")
Python says IndentationError: unindent does not match any outer indentation level. Each line in a block needs the same spacing. Use 4 spaces every time.
Python also raises a TabError when one line uses a Tab key and the next uses spaces. The two look identical on screen. Pick spaces, and set your editor to turn the Tab key into 4 spaces. The official PEP 8 style guide recommends 4 spaces per indentation level.

A NameError means Python met a name it doesn’t know. You used a variable, function, or module before creating it, or you spelled it differently.
Unlike the first two errors, NameError shows up while the program runs. The lines before it may work fine.
player_name = "Mia"
print(plyer_name)
Python says NameError: name 'plyer_name' is not defined. Did you mean: 'player_name'? Python spotted the typo and offered the fix. Take the hint.
Print("Hi")
Python says NameError: name 'Print' is not defined. Did you mean: 'print'? Python treats Print and print as different names. Almost every built-in command is lowercase.
print(Hello)
Python says NameError: name 'Hello' is not defined. Without quotes, Python thinks Hello is a variable. Write print("Hello") for text.
def show():
score = 5
show()
print(score)
Python says NameError: name 'score' is not defined. The variable score only exists inside show(). Learn why in our guide to what a variable is in Python.
import random
print(rnadom.randint(1, 6))
Python says NameError: name 'rnadom' is not defined. Did you mean: 'random'? Check your spelling after every import.
SyntaxError and IndentationError stop Python before it starts. NameError stops Python when it reaches the bad line. IndentationError is a special kind of SyntaxError, so they behave alike.
| SyntaxError | IndentationError | NameError | |
|---|---|---|---|
| When it appears | Before the program runs | Before the program runs | While the program runs |
| Main cause | Broken grammar | Wrong spaces at line start | Unknown name |
| Typical clue | expected ':', was never closed | expected an indented block | is not defined |
| Fix | Add the missing symbol | Align lines with 4 spaces | Fix the spelling or define it first |
If your child sees a line print before the error, they’re looking at a NameError or another runtime error. If nothing prints at all, it’s usually a SyntaxError or IndentationError.
Ready for a guided start?
Your child can learn to read errors with a live mentor in our Python course for kids . Turn screen time into skill time with hands-on projects that adapt to your child’s pace.
Book a free demo class →
Follow the same 5 steps every time. A steady routine builds confidence faster than guessing.
Quotable tip: Fixing one Python error at a time beats changing five things at once.
These 5 mistakes cause most beginner errors.
" into “. Python says SyntaxError: invalid character '“' (U+201C). ✅ Fix: Retype the quotes in your code editor.Kids who give up early often don’t lack talent. They lack a routine. Our guide on why a child wants to quit coding after two weeks explains how to keep motivation high.
You don’t need to read code to coach your child through an error. Ask questions and let your child find the answer.
Try these 5 prompts:
Explaining the problem aloud often solves it. That habit builds confidence, curiosity, and problem-solving.
An illustrative scene: Lily, age 9, wrote her first if statement and got expected ':'. Her mentor didn’t fix it. She asked, “What did Python expect?” Lily read the message, spotted the missing colon, and fixed it in 10 seconds. That’s the skill you want to build.
Not sure if your child is ready for typed code? Take our Is my child ready for coding classes quiz. Curious about a first lesson? See what a 7-year-old can do in a first coding lesson.
Once your child masters the first three, these errors appear. All messages below come from Python 3.13.
| Error | Example message | What it means |
|---|---|---|
| TypeError | can only concatenate str (not "int") to str | You mixed text and numbers |
| ValueError | invalid literal for int() with base 10: 'ten' | The value is the right type but wrong content |
| IndexError | list index out of range | You asked for a list spot that doesn’t exist |
| KeyError | 'dog' | A dictionary doesn’t have that key |
| AttributeError | 'list' object has no attribute 'add' | You used a method that doesn’t exist |
| ZeroDivisionError | division by zero | You divided by 0 |
| ModuleNotFoundError | No module named 'turtel' | You misspelled an import |
Older kids can catch errors on purpose with try and except:
try:
age = int(input("Age? "))
print("Next year:", age + 1)
except ValueError:
print("Oops! Type a number, like 9.")
Type ten and the program prints a friendly message instead of crashing. The official Python tutorial on errors and exceptions covers this in depth. Our tuples guide and Python coding challenges for beginners give your child safe places to practice.
Many kids can learn to read Python error messages from age 8 or 9, once they type confidently and read simple sentences. Younger kids often do better with Scratch first.
| Age | What to expect | Next step |
|---|---|---|
| 7–8 | Block coding builds logic first | Coding classes for 7-year-olds, 8-year-olds |
| 9–10 | First typed programs with mentor help | Coding classes for 9-year-olds, 10-year-olds |
| 11–12 | Reads most errors alone | Coding classes for 11-year-olds, 12-year-olds |
| 13+ | Handles tracebacks and try/except | Fundamentals of Python programming |
Still weighing languages? Our post on Python or Java: which should kids learn first and the Scratch vs Python comparison can help.
Try each one before you read the answers.
print("Hi there)if score > 5 followed by print("Win") on the next linefor i in range(3): followed by an unindented print(i)print(Score) after you wrote score = 5name = "Mia" followed by a second line that starts with 2 extra spaces: print(name)Answers
print("Hi there").if score > 5:.print(i) by 4 spaces.Score and score as different names. Use score.print(name) lines up with the line above.Want more? Try our Python programming quiz for kids or build a rock-paper-scissors game in Python, a calculator, or a hangman game. Every error your child fixes while building makes the next one easier.
Your child learns fastest with a mentor who turns every error into a small win. ItsMyBot courses adapt to your child’s pace, and you get regular progress updates.
Python course pages
Related guides
Python error messages are notes Python prints when it can’t run your code. Each one names the error type, the line number, and the reason. Reading them tells you exactly what to fix, so kids can solve most beginner problems without outside help.
A SyntaxError means your code breaks Python’s grammar rules, like a missing colon, an unclosed quote, or an unclosed bracket. Python finds it before the program runs, so nothing prints. Read the message, check the flagged line and the line above it, and add the missing symbol.
An IndentationError happens when a line has the wrong spacing at the start. Common causes are a missing indent after if, for, or def, extra spaces on one line, or mixing Tab and spaces. Use 4 spaces for every level and the error disappears.
A NameError means Python met a name it doesn’t recognize. Typos, wrong capital letters, missing quotes around text, and using a variable before creating it are the usual causes. Python 3.10 and newer often add a “Did you mean” hint with the correct name.
Almost. IndentationError is a special kind of SyntaxError that covers spacing problems at the start of a line. Both stop Python before the program starts. SyntaxError covers broken grammar anywhere, while IndentationError covers only wrong indentation. Fix either one by reading the message and checking the flagged line.
Most kids can start around age 8 or 9 with a mentor. They need steady typing and basic reading skills. Younger kids usually do better with Scratch first, then move to Python once they enjoy building projects. Our age-based classes match the pace to your child.
Ask guiding questions instead of giving the answer. Try “What’s the last line say?” and “Which line does Python mention?” Your child learns to read the message alone. A live mentor helps when they stay stuck, and our free demo class is a good place to start.
Python error messages help your child grow. SyntaxError, IndentationError, and NameError are the three most common, and each follows a clear pattern.
Every great coder reads errors every day. Give your child a mentor, a routine, and the confidence to keep going. Book a free demo class and watch curiosity turn into skill.
Turn screen time into skill time.
Help your child build real Python confidence with a live mentor.
Talk to our team →

Online coding, AI, and robotics classes that help kids ages 5–16 build real skills — and confidence — one project at a time.
No commitment · Live class with an expert teacher
© ItsMyBot 2026. All Rights Reserved.