A comparison operator identifies the relationship between the operands and results into
One such basic yet important operator is not equal operator in Python.
It returns True
if the values on either side of the operator are unequal i.e. it returns True when
two variables of same type have different values, else it returns False.
|!=||Not Equal operator, applicable and available in both Python 2 and Python 3.|
|<>||Not equal operator in Python 2, deprecated in Python version 3 and above.|
Python not equal Operator Syntax
operand1 != operand2
In the below snippet, 10 <> 20 results in a syntax error because it is deprecated in Python version 3 and above.
Python not equal Operator with custom object
Whenever we use the not equal operator, it calls
__ne__(self, other) function. Thus, the user can define their own custom implementation for the objects and manipulate the natural or default outcome/output.