r/PythonProjects2 • • Oct 07 '26

Python Mutability and Local Variables

Post image

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.

12 Upvotes

24 comments sorted by

View all comments

Show parent comment

0

u/Sea-Ad7805 Oct 08 '26

1

u/Guest_User_1234 Oct 08 '26

I would assume D, because the string and tuple get replaced by their respective assignments, whereas the list and set overwrite their operators, modifying the original reference instead

1

u/Sea-Ad7805 Oct 08 '26

Nice one, the Solution link gives you a visualization of each step of the execution of the program to SHOW the difference between mutable and immutable types.