Skip to content
Related Articles

Related Articles

Python None Keyword

View Discussion
Improve Article
Save Article
Like Article
  • 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.

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!