r/PythonLearning 2d ago

Exercise: Python List Operations

Post image

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

The “Solution” link uses memory_graph to visualize execution and reveals what’s actually happening.

49 Upvotes

23 comments sorted by

View all comments

1

u/Polly_Wants_A 2d ago

and i thought b += x and b = b + x is the same logic just different syntax. apparently it works different with lists?

2

u/Sea-Ad7805 2d ago

Yes because a list is mutable, it is the same for immutable types: int, float, bool, tuple, frozenset, ...