None

In Python, the None keyword represents the absence of a value or a null value. It’s an object that serves as a placeholder when you need to specify that a variable doesn’t hold any valid data or when a function doesn’t return any value.

Python None Keyword Examples

Here are a few examples demonstrating how None can be used in Python:

Python
>>> result = None
>>> print(result)
None

>>> def function(arg=None):
...     return arg
...

>>> print(function())
None

>>> value = None
>>> if value is None:
...     print("The value is None")
...
The value is None

In these examples, None is assigned to a variable as a placeholder, returned by a function that doesn’t explicitly return a value, and used in a conditional statement to check if a variable is None.

Python None Keyword Use Cases

  • Initializing variables to indicate that they don’t hold any value yet
  • Returning from functions when there’s no value to return
  • Defining default argument values
  • Signaling the end of a data structure, like the end of a linked list

Tutorial

Null in Python: Understanding Python's NoneType Object

In this tutorial, you'll learn about the NoneType object None, which acts as the null in Python. This object represents emptiness, and you can use it to mark default parameters and even show when you have no result. None is a tool for doing everything with nothing!

basics python

For additional information on related topics, take a look at the following resources:


By Leodanis Pozo Ramos • Updated Jan. 6, 2025 • Reviewed by Dan Bader