0 of 6 problems solved • 0%

Exercise prompt

Admit a Visitor

An early return can settle a special case before you consider the ordinary rules. Combine conditions with and or or when either or both must hold.

Example

def start_machine(powered, automatic, button): if not powered: return False return automatic or button print(start_machine(False, True, True)) # False

The early return handles a missing requirement. Only a powered machine reaches the second decision.

Your task

Complete may_enter(age, with_adult, closed). A closed gallery admits nobody. When open, anyone aged 12 or older may enter alone. Younger visitors need an adult. Return a boolean.