-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
26 lines (21 loc) · 682 Bytes
/
main.py
File metadata and controls
26 lines (21 loc) · 682 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# FILE: /structural_pattern_matching/main.py
def execute_command(command):
if command == 'ls':
print('$ listing files')
elif command == 'cd':
print('$ changing directory')
else:
print('$ command not implemented')
print('...rest of the code')
execute_command('ls')
def execute_command(command: str):
match command:
case 'ls':
print('$ listing files')
case 'cd':
print('$ changing directory')
case _: #1:
print('$ command not implemented')
execute_command('cd')
#1: Não é obrigatório usar 'case _:'. Este equivale ao 'else'.
# Edson Copque | https://linktr.ee/edsoncopque