Demoprogramme
This commit is contained in:
11
teil24/match_structure.py
Normal file
11
teil24/match_structure.py
Normal file
@@ -0,0 +1,11 @@
|
||||
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}')
|
Reference in New Issue
Block a user