promptdojo_

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

Checkpoint

One last thing before we move on. Same surface as a write step — but the lesson doesn't complete until this passes.

Last one. Cursor wrote apply_discount, a function that's supposed to take a list of order dicts and a percent, and return a new list of orders with the discount applied. The original orders should be unchanged.

Two bugs: it uses .copy() instead of deepcopy (so the inner dicts are shared), and it returns the wrong variable.

Fix the function so the script prints:

original first price: 100
discounted first price: 90.0

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