What is the purpose of ‘is’, ‘not’ and ‘in’ operators?
Last updated 2 years, 11 months ago | 1092 views 75 5

Python | ‘is’, ‘not’, and ‘in’ operators
is: Returns True if both variables are the same object
>>> x = 5
>>> y = 5
>>> z = 1
>>> x is y
True
>>> x is z
False
not: returns the inverse of the boolean value
>>> x = True
>>> not x
False
>>> y = False
>>> not y
True
in: Returns True if the specified value is present in a sequence.
>>> x = [5,10,2,9,7]
>>> 7 in x
True
>>> 3 in x
False