Copy Before You Change
Python
15 pts
Copy Before You Change
The starter code has a bug: changing new_prices also changes prices. Press Run to see it.
Fix the program by making new_prices a real copy with copy(). Keep the two changes. The output must be:
{'bread': 10, 'milk': 25}
{'bread': 10, 'milk': 30, 'tea': 40}
Checklist
- Make
new_pricesa separate dictionary so thatpricesdoes not change. - Keep the two changes to
new_prices. - Print both dictionaries.
🔑 Solution
If you view the solution before passing, you earn half points for this exercise. You still need to type it and press Check to finish.
How it works, step by step
Point at a step to highlight its lines. Type the solution yourself and press Check answer to finish.
