Keywords and Expressions
None — Absence of a value
None is the single instance of NoneType. It is commonly used for missing results, optional values, and functions that complete without an explicit result. It is falsy, but is not False, zero or an empty string. Test for absence with is None when other falsy values are valid. A default of None cannot distinguish an omitted argument from an explicitly supplied None; use a separate sentinel when that distinction matters. Assignment to None is invalid.
Formal Syntax & Structure
python syntaxpython
NoneReturn Value
NoneType
The singleton None object.
Working Example
Example Snippetpython
def lookup(label): if label == "pen": return 0 return None
for label in ("pen", "book"): value = lookup(label) print("missing" if value is None else value)