Why does this not add additional strings

Why does this not add additional strings to the the variable password?

password = []
password += "z"
password += "a"


This code results to [‘z’, ‘a’]. Why doesn’t your code result in a similar fashion ie: immutable strings?

By definition:

“Object is mutable only when we are able to change the values held in the memory location without changing the memory location itself.”

The point is:

“If the memory location before and after the change are the same, it is mutable.”

Immutable string example:

>>> word = 'cod'
>>> print(word)
>>> print(id(word))
>>> word += 'e'
>>> print(word)
>>> print(id(word))
140138931881720        # this id is different than previous one for the same valiable

Mutable list example:

>>> letters = ['c', 'o', 'd']
>>> print(letters)
['c', 'o', 'd']
>>> print(id(letters))
>>> letters += 'e'       # is the same as letters += ['e']
>>> print(letters)
['c', 'o', 'd', 'e']
>>> print(id(letters))
140138871021896       # list id is the same before and after change

Another example of immutable string:

>>> word = 'mode'
>>> word[0] = 'c'    # we are trying to change 'mode' to 'code'
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: 'str' object does not support item assignment

In the code provided, you are adding letters to an empty list:

password = []

Therefore you are going to get a list with the added letters.
The exercises actually asks us to define an empty string

password = ""

and add a letter through each iteration.