In this post we will be creating a Python script that will check if an existing variable is a none type, to do this we will be using the ‘is’ operator to carry out our checks.
To do this we will use the ‘is’ operator which will check if the objects are of the same identity.
See the snippet of code below where we create and test a none type variable.
Var = None if Var is None: print("Variable is NonType")
The above would return the following as output.
Variable is NonType >>>
Take a look at some of our other content around the Python programming language by clicking here.