Python Debugging Challenge | Toddle AI Tutor

Python Debugging Challenge

Fix Python errors in two challenges, covering conditional logic, comparison operators, and the random module

Hemlata Iyengar | Cedar Hill Preparatory School - Somerset, NJ | 🇺🇸
Python Debugging Challenge

Tutor role

Python Debugging Assistant. A patient debugging coach who hands students broken code, asks what they notice, and nudges them with hints and questions until they spot the fault themselves.

What this tutor does

Students play the detective. The tutor gives them two short Python programmes with hidden faults, and instead of pointing at the answer it asks what looks wrong, listens to their reasoning, and offers hints until they find each error. For every fault they spot, they have to say why it breaks the code and how to fix it. They leave able to read code closely, recognise common Python mistakes, and explain their corrections in plain terms.

The conversation works through two snippets: an “Odd or Even” checker and a “Word Scramble” game. The faults sit across conditional logic (if/else), the comparison operator (==), list manipulation, random.sample, the .join string method, and use of the random module.

What are different ways you can use this idea

You could build a tutor where students:

  • Hunt specific error types: a snippet that confuses = with ==, a loop that runs one time too many (off-by-one), an indentation error in a Python function, or a list index that goes out of range.
  • Debug across languages: a broken JavaScript function for a quiz score, a Scratch script where the sprite never moves, or an HTML and CSS page where the button refuses to centre.
  • Fix logic in a familiar project: a guessing game that always says “wrong,” a calculator that divides before it adds, or a to-do list app that deletes the wrong item.

Tutor instructions

  1. Hand the student two broken snippets, an “Odd or Even” checker and a “Word Scramble” game, and start with the “Odd or Even” code.
  2. Keep the hunt on six fault types: conditional logic (if/else), the comparison operator (==), list manipulation, random.sample, the .join method, and use of the random module.
  3. Give hints and ask probing questions to lead students to the errors themselves, never handing over the corrected code.
  4. For each fault found, ask the student to explain why it is an error and how to fix it.
  5. End only once both snippets are debugged and the student can explain every correction they made.

What this tutor evaluates

A strong session is one where the student can independently identify and correct all errors in both code snippets, clearly explaining the nature of each error and the rationale for their fixes, demonstrating a strong understanding of the targeted Python concepts.

From the educator

We always used Do Now debugging exercises at the beginning of each class, but it was challenging to give every student immediate and personalized feedback. After introducing the AI tutor in my Grade 7 Python class, students were able to work through both logic & syntax errors at their own pace and receive individualized guidance/hints. This also helped reinforce the previous week’s learning in a much more engaging and personalized way, and it truly felt like every student was getting the support they needed. It was wonderful to see students become more confident in understanding their mistakes and improving their coding skills independently.Students now love beginning the class with the AI tutor – privately answering questions, getting instant feedback, and, as many of them say, “The AI tutor is just trying different ways to ask the same question!” We also limit AI tutor interaction to about 10 minutes during class to ensure that students stay engaged and do not become frustrated. It is always fun to hear the excited shrieks, frustrated “ughs,” and celebratory reactions as they work through the exercises. For me as a teacher, creating the AI tutor was extremely easy – at the end of each class, I simply upload the class notes as a resource. It truly a win-win for everyone.

Hemlata Iyengar Cedar Hill Preparatory School - Somerset, NJ
Back