Consider the following:
x = 1
y = 1
print hex(id(x))
print hex(id(y))
Output:
0x2198158
0x2198158
x and y are two different variable that happen to hold the same value. Why is python assigning the same memory location to these two?
Next let us consider strings:
x = 'a'
y = 'a'
print id(x) == id(y)
Output:
True