Account
Categories

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 equal or not, you can use the equal to operator (==).

If it finds the same value, then it returns True; otherwise, it returns False.

Syntax:

a == b

Example:

password = "python123"

while True:
    user_password = input("Enter Password: ")

    if user_password == password:
        print("Login Successful")
        break
    else:
        print("Wrong Password")

Output:

Exercise

Create two variables num1 and num2 with the same value and check them using the equal to operator.