python not equal operator
Python, not equal operator returns True
if two variables are of the same type and have different values, if the values are same then it returns False
. Python is dynamic and strongly typed language, so if the two variables have the same values but they are of a different type, then not equal operator will return True
.
You can use != and is not for not equal operation in Python.
Example
str="halo" if str != "halo": print("Not Equal...") else: print("Equal...")