đ§ Day 7 â Debugging with AI: Learn the âWhy,â Not Just the Fix
Todayâs post is shortâbut foundational. Weâre not just learning how to fix errors. Weâre learning how to think through them with AI as a true assistant, not just a mechanic.
Letâs talk about debugging.
đŁ A Real Easter Example
Itâs Easter Sunday, and I decided to keep things light. So I fired up a simple number guessing game in Pythonâone I knew had a bug. The error? A common one:
TypeError: '<' not supported between instances of 'str' and 'int'
I pasted the broken code into Cursor and asked:
âCan you help me troubleshoot this code?â
Cursor reviewed it and said the syntax was fineâwhich was technically true. The error wasnât a missing colon or typo. It was a logic problem: input() returns a string, and I was comparing it directly to an integer.
I ran it again, but this time I included the actual error message. That changed everything. The AI found the issue, explained the problem, and offered a clean fix.
đ What You Should Learn From This
When debugging, the question you ask AI matters just as much as the code itself.
Don't just say:
âFix my code.â
Do ask:
âWhy am I getting this error?â
âWhat does this error message mean?â
âWhat are better ways to structure this logic?â
This teaches you not only how to fix one bugâbut how to approach any bug.
đ§Ș Todayâs Mini-Project: Debug the Game
Hereâs the broken version of the number guessing game. Run it. Then use your AI assistant to debug itânot just fix it.
import random
def guess_number():
secret_number = random.randint(1, 100)
guess = None
print("Welcome to the Number Guessing Game!")
print("I'm thinking of a number between 1 and 100.")
while guess != secret_number:
guess = input("Enter your guess: ")
if guess < secret_number:
print("Too low. Try again.")
elif guess > secret_number:
print("Too high. Try again.")
else:
print("Congratulations! You guessed the number.")
guess_number()
đĄ Hint: What data type does input() return?
âïž Reflect
What was the actual issue in the code?
How did the AI help you understand it?
How did your prompt shape the AIâs response?
Would you have spotted the bug without AI?
â
Completion Checklist
Ran the buggy number guessing game
Used AI to troubleshoot the error (with an error message!)
Learned the difference between syntax and logic errors
Wrote down what youâll do next time you see a weird bug
AI wonât always give you the answer on the first try. But if you learn to bring the right questions, youâll get better responsesâand become a much better developer.
See you tomorrow.
đș Share the video for this lesson: YouTube
đ Catch up on previous days: Zero to Builder Substack

