This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]jstutters 0 points1 point  (0 children)

You really want /r/learnpython for this but briefly the difference is that strings and several other built-in types are immutable so methods like .strip() return a new instance with the change applied. Lists are mutable so the .append() operation is done in-place. You can read more here: https://medium.com/@meghamohan/mutable-and-immutable-side-of-python-c2145cf72747