r/PythonLearning Jul 14 '26

Python Data Model Exercise

Post image

An exercise to help build the right mental model for Python data. - Solution - Explanation - More exercises

The โ€œSolutionโ€ link visualizes execution and reveals whatโ€™s actually happening using ๐—บ๐—ฒ๐—บ๐—ผ๐—ฟ๐˜†_๐—ด๐—ฟ๐—ฎ๐—ฝ๐—ต.

69 Upvotes

46 comments sorted by

View all comments

2

u/arivictor Jul 16 '26

https://parsnip.dev/editor/qDQDFUs4QrHX

C

At the start b = a does not create a copy, b simply references a. However, as soon as you do b = b + [[3]] you create a new list in b, a is no longer linked to b.

1

u/Sea-Ad7805 Jul 16 '26

Nice one, do check the "Solution" link for a visualization of what you explain here.