r/PythonLearning • • 10d 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

2

u/deadeye_82_1 4d ago

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

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

1

u/Sea-Ad7805 4d ago

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

1

u/Matikus28 9d ago

E?

1

u/Sea-Ad7805 9d ago

Incorrect sorry, see Solution link for correct answer.