Python uses None instead of null, so in this article, I'd like to show with you the best way to check if the variable is null (None)

Checking if a variable is null [Method 1]

syntax:

not variable:

example:


#variable
variable_1 = None

if not variable_1:
    print("yes! the var is null")

output

yes! the var is null

Checking if a variable is Null [Method 2]

syntax:

is None:

example:


#variable
variable_1 = None

if variable_1 is None:
    print("yes! the var is null")

output

yes! the var is null

English today is not an art to be mastered it's just a tool to use to get a result