# 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
True


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

Published on 11-Feb-2018 23:39:21