Simplify nested conditions
The function returns true only when both the age and badge checks pass.
def can_enter(age, has_badge):
if age >= 18:
if has_badge:
return True
return False
Refactor the control flow without changing which inputs are accepted.
Which expression preserves the function's behavior with less nesting?
Why it matters: Guard clauses can make the conditions for a successful path easier to see.