CodeWitness

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?