Editor settings

General settings

Save settings

Learn to program with Python

None in Python #

The value None, or often referred to as null value in many languages, is a special value in programming. It means there is no value, typically used when a function does not return anything or to initialize a variable without a value.

For example:

x = None
print(type(x)) # <class 'NoneType'>

print(x == True) # False
print(x == False) # False
print(x == 0) # False
print(x == "") # False
print(x == None) # True
print(x is None) # True

In the example above, we created a variable x and set its value to None. Note that the None value starts with a capitalized N. Note that None is not equal to any other value, except for None itself.


Exercise #

  • Create a new variable name and set its value to None.
Output will be displayed here