You can nest if statements inside other if statements.
For example:
if condition1:
if condition2:
#do something if both condition1 and condition2 are true
Be careful with your indentation so it is clear which text is under which header.
Logical operators, and, or, and not, can often be used to simplify complicated if statements.
The not operator comes before a boolean and reverses the truth value of a boolean.
The and and or operators come between two booleans. The and operator returns True only if both booleans are True, and returns false otherwise. The or operator returns True if one or both of the statements is True. In other words, or only returns False if both statements are false.
No Logical Operators
Logical Operators
not
if condition1:
pass
else:
#do it
if not condition1:
#do it
and
if condition1:
if condition2:
#do it
if condition1 and condition2:
#do something
or
if condition1:
#do it
elif condition2:
#do it
if condition1 or condition2:
#do it