Concept
Logical and (Both Must Be True)
Use `and` when both requirements must pass inspection:
python
has_key = True
knows_pin = True
if has_key and knows_pin:
print("Door unlocked")# 47. Logical and (Both Must Be True) Use `and` when both requirements must pass inspection: ```python has_key = True knows_pin = True if has_key and knows_pin: print("Door unlocked") ``` If even one side is `False`, the whole thing collapses to `False`. Zero exceptions allowed.
Checkpoint
What does `True and True and False` evaluate to?
Practice
Write an `if` checking if `ammo > 0 and health > 0` for `ammo = 5` and `health = 50`. If both pass, print `"Combat ready"`.
01
Tap code blocks below to assemble
Available Blocks