W3docs

Is there a "not equal" operator in Python?

Yes, in Python there is an operator for not equal (!=) .

Yes, in Python there is an operator for not equal (!=) . You can use it to compare two values and see if they are not equal to each other. For example:

The not equal operator != in Python

python— editable, runs on the server

This would output "x is not equal to y", because 5 is not equal to 3.

Additionally, there is a second way to express not equal comparison, this is with <> operator. It was used in python 2 but it's no longer supported in python 3.

The not equal operator <> in Python

python— editable, runs on the server

This would output "x is not equal to y", because 5 is not equal to 3.

And of course, you can also use the equality operator == to check for equality.

Check an equality in Python

python— editable, runs on the server

This would output "x is not equal to y", because 5 is not equal to 3.