r/PythonLearning • u/Sea-Ad7805 • Jul 14 '26
Python Data Model Exercise
An exercise to help build the right mental model for Python data.
The โSolutionโ link visualizes execution and reveals whatโs actually happening using ๐บ๐ฒ๐บ๐ผ๐ฟ๐_๐ด๐ฟ๐ฎ๐ฝ๐ต.
67
Upvotes
1
u/ghost59 Jul 14 '26
Oh! Wait. I'm stupid. You didn't make a copy of the values with b. You copied the original and when you change b you mutate a as well. It's because the list is something that can be mutated.
If I wanted a not to mutate. It would need to be B = a.copy()