Library › Coding AI › College students
See exactly what a mutable default argument does
Practice: Asking for a format you can use. About 5 minutes.
About this exercise
Your helper returns lists you didn't expect. Ask for exactly 4 numbered lines, one per print call, in the form 'Call 1 prints [...]', then one unnumbered line starting 'Why:' under 25 words. You want to fix it yourself, so no corrected code and no code blocks. Under 80 words in total.
Common mistakes when you ask AI for this
- Getting the fix handed over. The AI's default is the tags=None pattern, which skips understanding why. Try: Say: "Don't give me corrected code; I'll fix it myself."
- No trace. Without each call's output, you can't see the list growing. Try: Ask: "One line per call: Call 1 prints [...]."
- A long lecture. The AI explains default arguments, mutability and best practices at length. Try: Add: "Then one 'Why:' line under 25 words."
What a strong prompt includes
- Asks for a trace
- Sets the number of lines
- Asks for a short why
- Rules out the fix
Related exercises
- Add a cron line that matches the others in a crontab (Coding AI · Product managers)
- Add dark mode by overriding your existing CSS variables (Coding AI · Software developers)
- Add input checks to your number guessing game (Coding AI · High school students)
- Add input validation to a Java method with exact messages (Coding AI · Software developers)
- Add labels to a signup form without rewriting the page (Coding AI · High school students)