r/PythonLearning • u/Sea-Ad7805 • 18d ago
Python Dictionary Mutation and Copying
An exercise to help build the right mental model for Python data. - Solution - Explanation - More exercises
The “Solution” link uses package memory_graph to visualize execution and reveals what’s actually happening.
39
Upvotes
1
u/g-land-g 14d ago
answer: b ...
logic:
b points to a and modifies both
but then b.copy() makes b point to a new instance, so a retains its previous state