Python NOT EQUAL operator
In this article, we are going to see != (Not equal) operators. In Python != is defined as not equal to operator. It returns True if operands on either side are not equal to each other, and returns False if they are equal.
Note: It is important to keep in mind that this comparison operator will return True if the the values are same but are of different data types.
Attention geek! Strengthen your foundations with the Python Programming Foundation Course and learn the basics.
To begin with, your interview preparations Enhance your Data Structures concepts with the Python DS Course. And to begin with your Machine Learning Journey, join the Machine Learning - Basic Level Course
Syntax: Value A != Value B
Example 1: Comparing different values of the same data type
Example 2: Comparing same values of different data type
False True True
Example 3: Python not equal with custom object
The __ne__() gets called whenever the not equal operator is used. We can override this function to alter the nature of the not equal operator.