PythonNone
Python None
None is a special constant in Python that represents the absence of a value.
Its data type isNoneType, andNone is the only instance of aNoneType object.
NoneType
Variables can be assignedNone to indicate "no value" or "not set".
Usetype() to see the type of aNone value.
Comparing to None
To compare a value toNone, use the identity operatoris oris not
Example
Use the identity operatoris for comparisons withNone:
if result is None:
print("No result yet")
else:
print("Result is ready")
Example
Similar example, but usingis not instead:
if result is not None:
print("Result is ready")
else:
print("No result yet")
True or False
None evaluates toFalse in a boolean context.
Functions returning None
Functions that do not explicitly return a value returnNone by default.
Example
A function without a return statement returnsNone:
x = 5
x = myfunc()
print(x)

