Python or Keyword
Example
Return True if one of the statements are True:
x = (5 > 3 or 5 > 10)
print(x)
Try it Yourself »
Definition and Usage
The or
keyword is a logical operator.
Logical operators are used to combine conditional statements.
The return value will be True
if one of
the
statements return True
, otherwise it will
return False
.
More Examples
Example
Using the or
keyword in an
if
statement:
if 5 > 3 or 5 > 10:
print("At least one of the statements are
True")
else:
print("None of the statements are True")
Try it Yourself »
Related Pages
The keywords and
,
and not
are also
logical operators.
Read more about operators in our Python Operators Tutorial.
Copyright 1999-2023 by Refsnes Data. All Rights Reserved.