In Python, the ‘null’ object is the singleton None. The best way to check things for “Noneness” is to use the identity operator, is as shown below
1 2 3 4 5 6 7 8 9 10 11 12 13 |
a = None if a is None: print("a is Null") ## Returns a is Null else: print("a is not Null") a = "something" if a is None: print("a is Null") else: print("a is not Null") ## Returns a is not Null |