Intro to Coding with Blocks
Lesson 3 of 4 6 min +40 XP

Finding the Bug: Debugging

When a program misbehaves, hunt the mistake.

What you'll learn

  • Understand what a bug is
  • Read a program step by step
  • Fix a simple mistake in the order of blocks
The missing-sock hunt

Your laundry comes out with one sock missing, so you retrace every step to find where it vanished. Debugging is that same hunt in code — following the program's steps until you catch the exact spot where things went wrong.

A bug is just a mistake

When a program doesn't do what we wanted, there's a bug — a mistake in the steps. Good coders don't panic; they read the blocks one at a time and pretend to be the computer, doing exactly what each block says.

Be the computer

Trace through the steps slowly, in order. The place where what-you-expected and what-happens split apart is where the bug hides.

Blocks say: 'jump' then 'put on shoes'. The character jumps barefoot! Swap the order: 'put on shoes' then 'jump'.

Knowledge Check

+10 XP / correct

1. A 'bug' in a program is…

2. The best first step when debugging is to…