Python Tutorials · Python None
Python None
Learn all about Python None in this comprehensive tutorial.
5 min read beginner
- •None is a special constant in Python that represents the absence of a value.
- •Variables can be assigned None to indicate "no value" or "not set".
- •To compare a value to None, use the identity operator is or is not
- •None evaluates to False in a boolean context.
- •Functions that do not explicitly return a value return None by default.
Python None
None is a special constant in Python that represents the absence of a value.
Its data type is NoneType, and None is the only instance of a NoneType object.
NoneType
Variables can be assigned None to indicate "no value" or "not set".
python
Use type() to see the type of a None value.
python
Comparing to None
To compare a value to None, use the identity operator is or is not
python
python
True or False
None evaluates to False in a boolean context.
python
Functions returning None
Functions that do not explicitly return a value return None by default.
python
Module quiz
Test your knowledge on this module
5 questions