Chapter 17
Mutable and Immutable Objects
Over the last few chapters, you may have noticed some strange or confusing
things about strings and lists. The two types are very similar, but there are
significant differences that first appeared when we listed their methods.
Look again at the list of operations in the section “Lists Are Not Like Strings”
and at the note below the methods that modify lists on page 78:
These methods all modify the list they are called on, and only
.pop() returns anything.
Compare that with the note below the methods that seem like they should
modify strings on page 95:
None of these methods changes the original string; they modify ...

Get A Concise Introduction to Programming in Python now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.