Comparisons to the singleton objects, like True, False, and None, should be done with identity, not equality. Use “is” or “is not”


if var != True:
    print("var is not equal to True")
if var == None:
    print("var is equal to None")

Best practice

if var is not True:
    print("var is not True")
if var is None:
    print("var is None")