We are testing whether variables have a value or None, if they have values, we are printing their values.
# python code for not None test
# variable 1 with value
a = "Hello"
# variable 2 with None
b = None
# variable 3 with value
c = 10
# performing is not None test
if a is not None:
print("value of a: ", a)
else:
print("\'a\' contains None")
if b is not None:
print("value of b: ", b)
else:
print("\'b\' contains None")
if c is not None:
print("value of c: ", c)
else:
print("\'c\' contains None")
Output
value of a: Hello
'b' contains None
value of c: 10
We are testing whether variables have a value or None, if they have values, we are printing their values.
Output
need an explanation for this answer? contact us directly to get an explanation for this answer