← All examples

match / case

Python Switch / case

structural pattern matching

Flowchart (ISO 5807)

YesNoYesNoStartInput codecode == 1Return "один"Endcode == 2Return "два"EndReturn "інше"EndFigure 1 — name

Source code

def name(code):
    match code:
        case 1:
            return "один"
        case 2:
            return "два"
        case _:
            return "інше"