Fundamentals28 / 30
Up next

Match statement

def describe(n):
    match n:
        case 0:
            return "zero"
        case n if n < 0:
            return "negative"
        case _:
            return "positive"


print(describe(0), describe(-5), describe(9))
What you're solving

structural pattern matching (3.10+)