What is "is not" operator in Python?

PythonServer Side ProgrammingProgramming

In Python is not membership operator evaluates to false if the variables on either side of the operator point to the same object and true otherwise. For example −

>>> a = 10
>>> b = 20
>>> id(a), id(b)
(1581561184, 1581561504)
>>> a is not b

Since id() of variables a and b are different is not operator returns true.

Updated on 30-Jul-2019 22:30:21