None value
Python's special value meaning nothing here, which is what a function returns if it has no return statement.
In more detail
Seeing None printed where you expected a result usually means you printed the result of a function that prints instead of returning. None is falsy, and you test for it with is None. Type hints write optional values as str | None.
Example
result = print("hi")
print(result) # NoneRelated terms
- return statement — The statement return expression, which ends a function call immediately and hands the value back to the caller.
- truthiness — How Python treats any value as true or false in a condition: zero, empty collections, empty strings and None are false; nearly everything else is true.
- union type — A type that allows one of several listed types or values, written with a vertical bar, such as int | None in Python or "small" | "large" in TypeScript.
Taught in
- Reading A Traceback Like A Professional — Hands-on Python: Complete Video Course & Book
- Literals, Names And Four Number Bases — PCEP Certified Entry-Level Python Programmer (PCEP-30-02) Exam Prep