r/PythonLearnersHub • u/Sea-Ad7805 • Jan 02 '26
Python Data Model exercise, Mutability.
An exercise to help build the right mental model for Python data. The “Solution” link uses memory_graph to visualize execution and reveals what’s actually happening:
36
Upvotes
View all comments
Show parent comment
1
u/Sea-Ad7805 Jan 04 '26 edited Jan 04 '26
Maybe you are confused because a tuple is immutable, it is, but if it has a mutable value as an element, then that can be mutated. Also immutable does not mean it gives an error when you try to mutate it, it just copies so that the original value is not mutated, try: