The Python NOT EQUAL (!=) operator compares two values. It returns True if the values are not equal and False if they are equal. In this article, we will learn about NOT EQUAL in Python.

Python NOT EQUAL Operator Syntax

  • The syntax for the not equal to in Python is represented by the characters "!=".
  • It is used to check whether two operands are not equal to each other. Here's the syntax:
operand_1 != operand_2
  • Let's see an example where we are comparing a string and a numeric type.
  • Here, the string representation of the numeric value matches the string exactly, but the expression will evaluate to True because they are of different types, and Python treats it as different.
operand_1 = "5"
operand_2 = 5

result = operand_1 != operand_@ # Evaluates to True since "5" and 5 are not equal
print(result)  # Output: True\

Read More

#python #not equal

NOT EQUAL Operator in Python
3.05 GEEK