Take the following simple code.
a = "first"
b = "first"
print(id(a))
print(id(b))
id(a) is the same as id(b)
I am aware of the stack and heap situation. However, very unclear how does Python know that we have the same string here. I would expect python to create two objects in the heap. "a" would reference to one object and "b" would reference to another object.