r/PythonLearning • • 11d ago

Python Mutability, Sets and Shallow Copy

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.

29 Upvotes

4 comments sorted by

View all comments

2

u/deadeye_82_1 5d ago

b = b | {5} creates a new set.

b |= {4} does not create a new set

1

u/Sea-Ad7805 5d ago

Nice one, see solution link for visualization of correct answer.