r/PythonLearning • • 2d ago • Bravo 1

Python: Different Copying options

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.

41 Upvotes

4 comments sorted by

2

u/AQuestionIsWhatIHave 2d ago

Everything but deepcopy creates at best a shallow copy, therefore cx[0] for all x < 6 reference the same list a[0]. Thus it's D

1

u/Sea-Ad7805 2d ago

Great reasoning, see the Solution link for visualization of correct answer.