Lesson 10 — Explaining an error to the assistant
A good bug report gets a good fix
"My code doesn't work, fix it" forces the assistant to guess. A good bug report has:
- the code;
- what you expected;
- the error — the last line of the traceback;
- where it happened — the line number and that line of code.
A traceback is Python's error report. Read it from the bottom up: the last line is the error type and message; the File "...", line N just above it is where it happened, and the line under that is the code itself.
File "main.py", line 4, in average
total += s
TypeError: unsupported operand type(s) for +=: 'int' and 'str'
Handy string tools: text.strip().splitlines() gives a list of lines; lines[-1] is the last one; line.split("line ")[1] gives what comes after "line ".
Why it matters: the error is the most precise clue you have. Passing it on exactly is half of the fix.
Finish bug_report(): fill error with the last traceback line, and number + code_line from the last "File ..." line and the line after it.
Run your code — when the output matches the task, you will see a green check. Then mark the lesson complete.
A quick 3-question quiz on this lesson — instant feedback.
Ready for more? Optional paid resources that pick up where this lesson leaves off.
Some links on this page are affiliate links: we may earn a commission at no extra cost to you. As an Amazon Associate I earn from qualifying purchases.
Project-based Coding with AI: ChatGPT & Claude courses if you want a structured paid path after the free lessons. Wait for a sale — prices drop often.
Browse on Udemy →Search Amazon for Coding with AI: ChatGPT & Claude books — check the publication year so the examples match current versions.
Search Amazon →