Full lesson Debugging 3–7 min

Bugs: Find Them, Fix Them!

Bit's robot show went wrong! Can you find the bug?

Real Python code

This is the code from the video. Read it out loud like a recipe, one line at a time!

door.py
keys = 1

if keys == 0:
    print("The door opens!")
else:
    print("I need a key!")

Quiz time!

Bit wants to clap 3 times. Where's the bug?

quiz.py
for i in range(2):
    print("Clap!")

Three sneaky bugs

Wrong order

The steps are in a mixed-up order

Wrong count

A loop repeats too many or too few times

Wrong check

An if asks the wrong question

Bugs are normal

Every coder makes them, every day

Be a bug hunter

Bug panic

  • Change lots at once
  • Guess and hope
  • Give up
VS

Bug hunter

  • Read it slowly
  • Expected vs happened
  • Fix one, test again

Bugs are clues, not failures!

Try it yourself!

Build a tiny Scratch program with a bug in it on purpose, then ask a friend or family member to find it and fix it.

Bit is working on the next one: Functions: make your own blocks

Liked this quest?

Subscribe to see the next one first! Ask a grown-up before subscribing.

Keep exploring