This or
operator returns the first operand that evaluates to True or the last one if all are False.
A or B
Here,
Note: False, None, numeric zero of all types, and empty strings and containers (including strings, tuples, lists, dictionaries, sets, and frozensets), these all are interpreted as False. And the rest of others are interpreted as True.
>>> x or y
Here, first, x is evaluated; if x is true, its value is returned; otherwise, y is evaluated and the resulting value is returned.
>>> 0 or '' or False
False
>>> 1 or '' or False
1
>>> 1 or 'A' or False
1
>>> 1 or 2 or 3
1
>>> b = '' and 'ABCD'
>>> b
'ABCD'
>>> b = 0 and 1
>>> b
1
Return True
if one of the statements are True
, otherwise, it will return False
.
>>> if 13 > 7 or 13 < 10;
... print("One of the statements is True")
... else:
... print("None are True")
...
'One of the statements is True.'