r/PythonLearning • u/Sea-Ad7805 • 10d ago
Python Mutability, Sets and Shallow Copy
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
1
2
u/deadeye_82_1 4d ago
b = b | {5} creates a new set.
b |= {4} does not create a new set