Debugging Like a Detective: Predict, Run, Fix

← Back to Blog & Articles

Every programmer writes bugs. The difference between beginners and experienced coders is not avoiding mistakes, but finding and fixing them calmly.

A bug is a clue

When a program does not work, something is different from what you expected. The goal is to find where your expectation and the computer's behavior part ways.

A simple routine

  1. Predict. Before running, say what you think will happen.
  2. Run. See what actually happens.
  3. Compare. Where did it differ?
  4. Change one thing. Make the smallest change you can and run again.

Read the error message

Python's messages are helpful once you know how to read them. They tell you the kind of error and the line number where it happened. Start there.

Common beginner bugs

  • Missing colon or quotation mark.
  • Wrong indentation.
  • Using = when == was meant.
  • Misspelling a variable name.
  • Forgetting to convert input to a number.

Make bugs visible

Add a print to show what a variable holds at a certain moment. This is a simple, powerful way to see what the program is doing.

Help without taking over

Parents and mentors can ask, "What did you expect? What did you get? What could you try?" This builds independence and confidence.

Celebrate fixes

A found bug is a small win. Treating mistakes as normal makes learners braver and better.

Takeaway

Debugging is a skill that can be practiced, and it is one of the most valuable parts of learning to code.

Continue with the book

Explore the full treatment, worked examples, and exercises in Code Quest with Python.


Adapted from Code Quest with Python, published by Choral Software. Article text and original examples © 2026 Choral Software. All rights reserved.

Scroll to Top