How to Check Whether Either of Two Conditions Is True in Python with or
"Is it Saturday or Sunday?" is two questions with one answer: yes if either is true. Python writes that with or. It also checks the two in order and stops early, which lets you guard a test that would fail on bad data. This guide shows both on Python 3.15.2.
Syntax
if <first condition> or <second condition>:
<code to run when at least one is true>
| Part | What it means |
|---|---|
<first condition> | Checked first |
or | Makes the whole test true when either side is true |
<second condition> | Checked only when the first one is false |
The Python language reference puts it exactly: "The expression x or y first evaluates x; if x is true, its value is returned; otherwise, y is evaluated and the resulting value is returned." So when the first condition is true, Python never looks at the second.
The Example
The first script tells weekend days from weekdays with one or. The second checks a name that may be None, where the order of the two conditions decides whether the script works.
Prerequisites
- uv and Python 3. This guide uses uv 0.13.10 with Python 3.15.2, in a project made with
uv init.
Step 1: Write the Script
day = "Sunday"
if day == "Saturday" or day == "Sunday":
print("Weekend")
else:
print("Weekday")

Each side of or is a full comparison. day == "Saturday" or "Sunday" would not do the same thing, as Common Mistakes shows.
Step 2: Run It
uv run python weekend.py
Weekend

day == "Saturday" was False, so Python checked day == "Sunday", which was True, and the whole test was True. The command works unchanged in PowerShell.
Step 3: Let the First Condition Guard the Second
len(name) fails when name is None. Put the None check first, and Python never reaches len() for a missing name:
name = None
if name is None or len(name) == 0:
print("No name given")
uv run python name_check.py
No name given
Now swap the two conditions:
name = None
if len(name) == 0 or name is None:
print("No name given")
uv run python name_check_swapped.py
Traceback (most recent call last):
File "/Users/you/source/python-basics/name_check_swapped.py", line 3, in <module>
if len(name) == 0 or name is None:
~~~^^^^^^
TypeError: object of type 'NoneType' has no len()

With name is None first, the test was True straight away, so len(name) never ran. With len(name) first, Python ran it on None and stopped with a TypeError before it reached the None check.
Common Mistakes
| Mistake | What happens | Do this instead |
|---|---|---|
if day == "Saturday" or "Sunday": | Always true: with day = "Monday" it printed Weekend, because the right side is just the text "Sunday", which counts as true on its own | Write the full comparison on both sides |
Putting the risky test first, as in len(name) == 0 or name is None | TypeError: object of type 'NoneType' has no len() | Put the guard first |
Using or when both must be true | The code runs when only one is | Use and |
FAQ
What does or give outside an if?
One of its two values, not always True or False: the reference says it returns the first value if that one is true, otherwise the second. That's what makes name = given or "Guest" work.
Can I chain more than two conditions?
Yes: a or b or c checks them from left to right and stops at the first true one.
Conclusion
day == "Saturday" or day == "Sunday" printed Weekend for Sunday. With name is None first, the check printed No name given and never called len(); with the order swapped, it stopped with a TypeError.
Additional Resources
- Boolean operations —
or,andandnotin the language reference. - Truth value testing — which values count as true or false.
