That's not a "null" variable - the variable doesn't exist... there's a distinct difference between something not existing and existing with a "null" value (in Python that's normally the None singleton)
Sign up to request clarification or add additional context in comments.
Comments
15
try:
if val is None: # The variable
print('It is None')
except NameError:
print ("This variable is not defined")
else:
print ("It is defined and has a value")
try : exceptblock to check if the error is being thrownNonesingleton)