Home › Python Tutorial › Python match
Python match
Pattern matching (Python 3.10+).
match compares a value against case patterns. _ is the default that matches anything.
Example code
day = 3
match day:
case 1:
print("Mon")
case 2:
print("Tue")
case 3:
print("Wed")
case _:
print("Other")