Strings are immutable in Python
greeting = "Hello"
name = "Dmitri"
greeting = greeting + ", my name is " + name
print(greeting)
In the above example, first greeting is not the same object as the previous one and that is because that strings in Python are immutable - it means that they cannot be changed.
So, when you did the reassignment, essentially - you created a new string with the same name. However: the both variables are different objects. You can see it by using the
id function:
greeting = "Hello"
print(id(greeting))
name = "Dmitri"
greeting = greeting + ", my name is " + name
print(id(greeting))
Output:
140270949458736
140270949348336
So, you can see that the id's are different.