Account
Categories

Less Than or Equal to Operator (<=)


Definition:

It is a relational operator used in a programming language.

If you want to check whether the value of the left operand is less than or equal to the right operand, you use the less than or equal to operator (<=).

If it finds the condition true, then it returns True; otherwise, it returns False.

Syntax:

a <= b

Example:

attempt = 1

while attempt <= 3:
    print("Login Attempt:", attempt)
    attempt += 1

Output:

Login Attempt: 1
Login Attempt: 2
Login Attempt: 3

Exercise

Create a variable i = 1 and run a loop until i is less than or equal to 5 using the <= operator.