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

Practice this now ↑

Related exercises