What is the None keyword in Python?
The None keyword is used to define a null variable or an object. In Python, None keyword is an object, and it is a data type of the class NoneType.
We can assign None to any variable, but you can not create other NoneType objects.
Note: All variables that are assigned
Nonepoint to the same object. New instances ofNoneare not created.
Syntax
The syntax of None statement is:
None
Note:
Nonestatement supports bothisand==operators.
Interesting Facts
Noneis not the same asFalse.Noneis not 0.Noneis not an emptystring.- Comparing
Noneto anything will always returnFalseexceptNoneitself.
Examples
- Checking if a variable is
Noneusingisoperator:
# Declaring a None variablevar = Noneif var is None: # Checking if the variable is Noneprint("None")else:print("Not None")
- Checking if a variable is
Noneusing==operator:
# Declaring a None variablevar = Noneif var == None: # Checking if the variable is Noneprint("None")else:print("Not None")
- Check the type of
Noneobject:
# Declaring a variable and initializing with None typetypeOfNone = type(None)print(typeOfNone)
- Comparing
NonewithNonetype:
# Comparing None with none and printing the resultprint (None == None)
- Comparing
NonewithFalsetype:
# Comparing none with False and printing the resultprint(None == False)
- Comparing
Nonewith emptystring:
# Declaring an empty stringstr = ""# Comparing None with empty string and printing the resultprint (str == None)
Free Resources
Copyright ©2025 Educative, Inc. All rights reserved