Skip to content

Python null variable | None var Example code

  • by

There’s no variable null in Python; instead, there’s None keyword. It is a data type of the class NoneType

Python null variable

Example code. In Python, the ‘null’ object is the singleton None. The None keyword is used to define a null variable or an object.

var = None

if var is None:  # Checking if the variable is None
    print("Not None")


Python null variable

Variable = None in Python? What does it mean?

It sets a variable named variable to None (Python’s version of a null/none type object).

See a demonstration example below:

variable = None


<class 'NoneType'>

Is it possible only to declare a variable without assigning any value in Python?

Do this:

var = None

Do comment if you have any doubts and suggestions on this Python basic variable 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.

Leave a Reply

Your email address will not be published. Required fields are marked *