DEV Community 👩‍💻👨‍💻

Discussion on: id() in python

Collapse
rajshiikhar1691999 profile image
Rajshiikhar1691999

a = 500
id1 = id(a)
a = 150
id2 = id(a)
print(id1 == id2)
Now it is false na.

Collapse
siddhesh_agarwal profile image
Siddhesh Agarwal Author

The example is talking about re-initialization with same value like this:

a = 150
id1 = id(a)
a = 150
id2 = id(a)
print(id1 == id2)
Enter fullscreen mode Exit fullscreen mode

The above code gives True