Python None Keyword

The None keyword in Python is used when we need to declare a variable with no value at all. The interesting thing about the None keyword is, it is a constant value with no value at all.

None is neither a 0 nor an empty string like "". That is, None is None, nothing else. For example:

a = None
b = 0
c = ""

The output is:

<class 'NoneType'>
<class 'int'>
<class 'str'>

It means that, like 0 is of int type, "" is of str type. Similarly, None is of NoneType value.

Note - Python is a case-sensitive language, therefore keep the first letter of None keyword in capital letter, and remaining 3 letters must be in small letters.

Python None Keyword Example

Here is an example of None keyword in Python. This program demonstrates that, a function with no return value will return None:

def funOne():
    x = 10

def funTwo():
    x = 100
    return x

x = funOne()

x = funTwo()

The output is:


Python Online Test

« Previous Tutorial Next Tutorial »

Follow/Like Us on Facebook

Subscribe Us on YouTube