Skip to content
Related Articles

Related Articles

Improve Article
Save Article
Like Article

Python None Keyword

  • Difficulty Level : Easy
  • Last Updated : 12 Nov, 2020

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 None
print(type(None))
Output
<class 'NoneType'>

Example 2:

Python3




# declaring a variable as None
var = None
  
# checking it's value
if 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.

My Personal Notes arrow_drop_up
Recommended Articles
Page :

Start Your Coding Journey Now!