mutation — why your code mysteriously breaks8 / 8
mutation and the action-at-a-distance bug
Checkpoint
One last thing before we move on. Same surface as a write step — but the lesson doesn't complete until this passes.
One last thing. AI wrote a function tag_user that's supposed to return a
new user dict with one extra tag, leaving the original user alone. Right
now it mutates the input.
Finish the function so the script prints two lines: the original user
unchanged, and the new user with "vip" added to its tags.
Expected output:
original tags: ['pm']
tagged tags: ['pm', 'vip']
⌘↵ runs the editor.
Booting Python…
Output
[promptdojo:~]$ _