r/PythonLearning • u/Sea-Ad7805 • Aug 23 '26
Python Dictionary Mutation and Copying
An exercise to help build the right mental model for Python data.
The “Solution” link uses package memory_graph to visualize execution and reveals what’s actually happening.
38
Upvotes
1
u/g-land-g Aug 28 '26
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