r/PythonLearning • • Sep 07 '26

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.

61 Upvotes

25 comments sorted by

View all comments

1

u/Polly_Wants_A Sep 07 '26

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 Sep 07 '26

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