Python None Keyword
None is used to define a null value. It is not the same as an empty string, False, or a zero. It is a data type of the class NoneType object.
Assigning a value of None to a variable is one way to reset it to its original, empty state.
Attention geek! Strengthen your foundations with the Python Programming Foundation Course and learn the basics.
To begin with, your interview preparations Enhance your Data Structures concepts with the Python DS Course. And to begin with your Machine Learning Journey, join the Machine Learning - Basic Level Course
Example 1:
Python3
# we will check the type of Noneprint(type(None)) |
Output
<class 'NoneType'>
Example 2:
Python3
# declaring a variable as Nonevar = None # checking it's valueif var is None: print("var has a value of None")else: print("var has a value") |
Output
var has a value of None
Note: If a function does not return anything, it returns None in python.


