Files
pythonkurs/teil24/match_structure.py
2024-02-02 13:47:29 +01:00

12 lines
351 B
Python

values= ['John']
# Matching structure in Python switch-case
match values:
case [a]:
print(f'Only one item: {a}')
case [a, b]:
print(f'Two items: {a}, {b}')
case [a, b, c]:
print(f'Three items: {a}, {b}, and {c}')
case [a, b, c, *rest]:
print(f'More than three items: {a}, {b}, {c}, as well as: {rest}')