Account
Categories

Not Equal to Operator (!=)


Definition:

It is a relational operator used in a programming language.

If you want to check whether two values stored in operands are not equal, you use the not equal to operator (!=).

If it finds different values, then it returns True; otherwise, it returns False.

Syntax:

a != b

Example:

saved_otp = 54678
user_otp = 2323

if user_otp != saved_otp:
    print("Invalid OTP")
else:
    print("OTP Verified")

Output:

Exercise

Create two variables num1 and num2 with different values and check them using the not equal to operator.