Skip to content

match / case

Python structural pattern matching

Flowchart (ISO 5807)

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

Source code

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

The editor opens with this code — change it and the chart redraws.

Language
Python
Constructs
structural pattern matching
Topic
Switch / case
Formats
Word, Visio, draw.io, PDF, SVG

Related examples