VOOZH about

URL: https://www.geeksforgeeks.org/python/python-none-keyword/

⇱ Python None Keyword - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

Python None Keyword

Last Updated : 8 Jun, 2026

None is a special keyword that represents the absence of a value. It is commonly used to indicate that a variable has no value assigned or that a function does not return anything explicitly.


Output
None

Explanation: show() does not contain a return statement so, Python automatically returns None.

Common Uses of None

  • Initializing variables: Assign None when a variable is created but its actual value will be assigned later.
  • Representing missing data: Use None to indicate that a value is currently unavailable or does not exist.
  • Default function arguments: Set parameters to None when an argument is optional and a value may or may not be provided.
  • Indicating no return value: Functions that do not explicitly return a value automatically return None.

None vs Other Empty Values

Although None, False, 0 and "" may all behave as false values in conditions, they represent different things in Python.


Output
False
False
False

Explanation:

  • None represents the absence of a value and False represents a boolean false value.
  • 0 represents the numeric value zero and "" represents an empty string.

Examples

Example 1: The following example assigns None to a variable. This is often used to indicate that a variable currently has no value.


Output
None
<class 'NoneType'>

Explanation: x = None assigns the special value None to x and type(x) returns NoneType, which is the data type of None.

Example 2: The following example checks whether a variable contains None using the is operator.


Output
No value assigned

Explanation:

  • is None is the recommended way to check whether a variable contains None.
  • Since x is None, the condition evaluates to True.

Example 3: The following example uses None as a default parameter value when no argument is provided.


Output
Hello, Guest
Hello, Emma

Explanation:

  • name=None sets None as the default value.
  • When no argument is passed, name remains None and the default message is displayed.
Comment
Article Tags:
Article Tags: