r/learnmachinelearning • • 1d ago

Python Mutability: tuple vs list

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.

3 Upvotes

5 comments sorted by

View all comments

Show parent comment

6

u/crayphor 1d ago

I think it's more that += does a concatenation, then an assignment. It is not editing the tuple, it is creating a new tuple and assigning it as the value of the variable.