promptdojo_

Instance vs class attributes — and the bug AI ships every time — step 6 of 9

Claude wrote a Player class with an inventory = [] at the class level. Two players share the same inventory list. The output is ['sword', 'shield'] ['sword', 'shield'] instead of ['sword'] ['shield'].

Move the list into __init__ so each player gets its own. After the fix the output should be:

['sword'] ['shield']
The break is on line 2 — but read the whole snippet first.

full-screen editor opens — close anytime to keep reading.