Facebook Page Twitter Page LinkedIn Page
× Python Tutorial Python Advanced Python Resources Python Libraries


The Python or keyword is a logical operator which returns true when either of its operands is true, otherwise it returns false.

Syntax

(expression_1 or expression_2)
(operand_1 or operand_2)           

Example:

In the below example, or keyword is used to combine multiple conditions to execute a block of code only when any of the condition is true.

day = "FRI"
if (day == "SAT" or day == "SUN"):
  print ("Its weekend.")
else:
  print ("Its weekday.")

The output of the above code will be:

Its weekday.

Example:

In the below example, or keyword is used to combine multiple conditions and returns True only when any of the condition is true.

day = "SAT"
print (day == "SAT" or day == "SUN")

The output of the above code will be:

True

❮ Python Keywords