test = "hello world" if test is not None: print("test is not None") test2 = None if test2 is None: print("test2 is None")
Here is what the above code is Doing:
1. We create a variable called test and set it to “hello world”.
2. We check if test is not None. Since it’s not None, we print “test is not None”.
3. We create a variable called test2 and set it to None.
4. We check if test2 is None. Since it is None, we print “test2 is None”.