How Do You Use “not Equal” in Python?

The syntax for the “not equal” operator is != in the Python programming language. This operator is most often used in the test condition of an “if” or “while” statement.

The test condition a != b returns false if a is equal to b, or true if a is not equal to b. A programmer can use this expression in the statement if(a != b) followed by an indented block of code, in which case the indented code block is only executed if a is not equal to b. In older versions of Python, the “not equal” operator could also be written as <>.