How to use not equal operator in python

The != operator in Python stands for "not equal to." 

If the operands on either side are not equal, it returns True; if they are, it returns False. Python is dynamically, but strongly typed, and other statically typed languages would traceback or would give error about comparing different types. So, if tow variables have the same values but they are of different type, then not equal operator will return True.

Example-

  1)           5 == 5 --> True

                4  != 5 --> False

   2)          str = 'hey' 

                if str == 'hey':     # equal  
                elif str != 'hey':   # not equal


        


Comments