promptdojo_

Shallow copy, deep copy, and the nested-dict bug — step 6 of 9

Claude wrote a "make a backup before editing" snippet. The bug: it used .copy() on a nested dict. When the script edits the backup's nested tags list, the original list also changes.

The expected output is:

original tags: ['admin']
backup tags:   ['admin', 'temp']

Right now it's:

original tags: ['admin', 'temp']
backup tags:   ['admin', 'temp']

Fix line 5 so the backup is truly independent. The copy module is already imported on line 1.

The break is on line 5 — but read the whole snippet first.

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