promptdojo_

This is the single most famous Python bug — and AI ships it constantly.

The function add_pet uses pets=[] as a default. The trap: that empty list is created once, when the function is defined, not each time it's called. Every call without an argument shares the same list.

Run it as-is and you'll see the second call returns ["luna", "moose"] instead of just ["moose"]. Fix line 1 so each call without an argument gets a fresh list.

Expected output:

['luna']
['moose']
The break is on line 1 — but read the whole snippet first.

this step needs the editor

on desktop today; in the app (coming soon). save your spot and we'll bring you back here when you're ready.

open this same url on a laptop to keep going today.