Python None Keyword 🚫
The None Keyword
The None keyword is used to define a null value, or no value at all. None is not the same as 0, False, or an empty string. None is a data type of its own (NoneType) and only None can be None.
✨ Basic Usage
python
x = None
print(x)
if x:
print("Do you think None is True?")
elif x is False:
print ("Do you think None is False?")
else:
print("None is not True, or False, None is just None...")🔍 Checking for None
To check if a variable is None, use the is operator:
python
x = None
if x is None:
print("x is None")💡 Did You Know?
Functions that do not return a value, return None by default.
python
def my_function():
print("Hello")
x = my_function()
print(x)
# Output: None