To check multiple conditions in an if statement in Python, combine them with the boolean operators and, or and not, and use parentheses to make the grouping clear. if age >= 18 and has_id: runs only when both parts are true, while if day == "Sat" or day == "Sun": runs when at least one is.
This guide covers python multiple conditions in an if statement for beginners: the three operators, how they are evaluated, and shorter ways to write common checks such as membership and ranges. Examples work on Python 3.13 and 3.14.
andornotelif for mutually exclusive casesandand is true only when both sides are true.
If either side is false, the whole condition is false and the else branch runs. You can chain more than two checks: if a and b and c: needs all three.
oror is true when at least one side is true.
A common beginner mistake is writing if day == "Sat" or "Sun":. This does not mean what it looks like. The part "Sun" is a non-empty string, which counts as true, so the whole condition is always true. Repeat the comparison on each side, or use in as shown below.
notnot flips true to false and false to true.
Use not with in as x not in items and with identity as x is not None. Both read more naturally than not (x in items).
When you mix operators, Python evaluates not first, then and, then or. This table lists them from highest to lowest priority.
| Priority | Operator | Meaning |
|---|---|---|
| 1 | not | Reverses a condition |
| 2 | and | Both must be true |
| 3 | or | At least one must be true |
So a or b and c is read as a or (b and c). Add parentheses even when they are not required, because they show your intent.
Without the parentheses the same text would group differently and give a different result for some inputs.
Python evaluates and and or from left to right and stops as soon as the result is known. With and, if the left side is false, the right side is never evaluated. With or, if the left side is true, the right side is skipped.
This lets you guard an expression that could fail:
Because items is an empty list, which is falsy, items[0] is never run and no IndexError occurs. Put the cheap or safe check first.
Python allows a range test without repeating the variable:
This is the same as score >= 60 and score < 80, and it reads like a math inequality.
inInstead of many or comparisons against one variable, test membership in a tuple, set or list:
any() and all()When you have a list of conditions, all() behaves like a chain of and, and any() like a chain of or.
Empty strings, empty collections, 0 and None count as false in a condition. So if name and age > 0: checks that name is not empty and age is positive. Use an explicit comparison such as if x is None: when 0 or an empty string is a valid value that you do not want treated as missing.
elif for mutually exclusive casesIf conditions exclude each other, use elif rather than several independent if statements. Only the first matching branch runs.
if in Python?Yes. Join them with and when both must be true or with or when either is enough, for example if x > 0 and y > 0:.
if x == 1 or 2: always run?Python reads it as (x == 1) or 2, and the number 2 is truthy. Write if x == 1 or x == 2: or if x in (1, 2):.
&& and ||?No. Python uses the words and and or. The symbols & and | are bitwise operators, and on booleans they do not short-circuit.
and or or?and binds tighter than or. Use parentheses to be explicit.
Use and, or and not to combine conditions in one if. not is applied first, then and, then or, so add parentheses for clarity. Evaluation short-circuits left to right, which lets you guard risky expressions. Prefer chained comparisons, in, any() and all() when the condition gets long.