Skip to content

How to check NoneType in Python

Use is operator to check NoneType in Python, like the below code. Since None is the sole singleton object of NoneType in Python, we can use is operator to check if a variable has None in it or not.

if variable is None:

Note: if you declare two or more variables with the value None, they will refer to the same NoneType object.

How to check NoneType in Python

A simple example code determining a variable’s type is NoneType in Python.

x = None

if x is None:
    print("X is not None")


How to check NoneType in Python

Do comment if you have any doubts or suggestions on this Python NoneType topic.

Note: IDE: PyCharm 2021.3.3 (Community Edition)

Windows 10

Python 3.10.1

All Python Examples are in Python 3, so Maybe its different from python 2 or upgraded versions.

1 thought on “How to check NoneType in Python”

Leave a Reply

Discover more from Tutorial

Subscribe now to keep reading and get access to the full archive.

Continue reading