Junior Codes
Clockwork Woods

Debugging Python for Kids: How to Find and Fix Bugs

Read errors like clues and fix a program that almost works.

Start Wonderwild free with Pip

Try 5 starter activities free. Full access is ₹499 a year.

This mission is part of full access. The first missions are free to try.

Debugging, explained simply

A bug is a mistake in a program. Every programmer, including professionals, writes bugs every day. What makes someone good at coding is how calmly they find and fix them.

Start with the error message. The last line names the kind of problem and the line number shows roughly where it is. Common ones for beginners are NameError (a misspelt name), SyntaxError (a missing colon or bracket) and IndentationError.

Some bugs do not cause an error at all: the program runs but does the wrong thing. For those, add print() lines to check what your variables hold at each step, and change one thing at a time.

Example: Spot the two bugs

steps = 3
for step in range(steps)
    print("Step", stpe)

Output

SyntaxError: expected ':'

Add the colon after range(steps), run it again, and Python will point you to the second bug: stpe should be step.

Try this

  • Fix the example one bug at a time and read each new error message.
  • Break a working program on purpose in three different ways and write down each error name.
  • Explain your code out loud to a toy or a family member. It is a real technique called rubber duck debugging.

Practise it in Wonderwild

“Rescue across the river”

Mission 18 in Clockwork Woods, one of 36 Python missions in Wonderwild.

Your child writes and runs real Python in the browser while Pip reacts to every line. Nothing to install. For ages 7+.

Start Wonderwild free with Pip

Try 5 starter activities free. Full access is ₹499 a year.

This mission is part of full access. The first missions are free to try.

Questions parents and kids ask

Why does Python only show one error at a time?+

Python stops at the first problem it cannot get past. Fix it, run again, and it will show the next one if there is one.

How can parents help a child who is stuck on a bug?+

Ask questions rather than giving the answer: what did you expect to happen, what happened instead, and which line do you think is involved? Most children find the bug while explaining.

Prefer learning with a teacher?

Our live Python for Young Developers course teaches these ideas in small online classes led by a software engineer, with projects and feedback. Every live course also includes 12 months of full Wonderwild access for practice.

See the Python for Young Developers course