In Python, there is no such thing as Null.
Instead, there is a None
that can be easily used in if
conditions, functions, and classes.
None
is not equivalent to 0, False, Null, or an empty variable. It is its own type.
To check that a variable is None
, we use the is
operator:
myvar = Noneprint(myvar is None) #Truez = Noneprint(z) #None
We can also use it as the result of a function:
def get_none():passmyret = get_none()print(myret is None) #True