MemotivaPattern matching

What is pattern matching in Python?

Pattern matching

Audio flashcard · 0:17

Nortren·

What is pattern matching in Python?

0:17

Pattern matching, introduced in Python 3.10 via PEP 634, is a control structure that compares a value against patterns and executes the matching branch. It uses the match and case keywords. Patterns can match literals, types, sequences, mappings, classes, and combinations.
peps.python.org