
Python None
None is a special constant in Python that represents the absence of a value.
Its data type is NoneType.
Assign and display a None value:
x = None
print(x)Comparing to None
To compare a value to None, use the identity operator is or is not.
result = None
if result is None:
print("No result yet")
else:
print("Result is ready")True or False
None evaluates to False in a boolean context.
Check truthiness:
print(bool(None))Functions returning None
Functions that do not explicitly return a value return None by default.
def myfunc():
x = 5
x = myfunc()
print(x)