I am trying to understand how Python memory management works. If I have an mutable variable, say a list:
x = ['x1', 'x2']
print(id(x))
then I will get a certain memory address.
If I now modify x say x.append('x3'), the memory address is the same as before because lists are mutable data types. If, however, I change x with x = x + ['x3'] and I print the address I get a different one. Why it is so? I mean, the x variable has still the same name and all I have done is to modify its content. Why does Python change the address of the variable in this case?
x. You did not "just modify it's content". To modify the content dox += ['x3']