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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
|
match command.split():
# ^ conditional
case ["quit"]:
# ^ conditional
print("Goodbye!")
quit_game()
case ["look"]:
# ^ conditional
current_room.describe()
case ["get", obj]:
# ^ conditional
character.get(obj, current_room)
case ["go", direction]:
# ^ conditional
current_room = current_room.neighbor(direction)
# The rest of your commands go here
match command.split():
# ^ conditional
case ["drop", *objects]:
# ^ conditional
for obj in objects:
character.drop(obj, current_room)
match command.split():
# ^ conditional
case ["quit"]: ... # Code omitted for brevity
case ["go", direction]: pass
case ["drop", *objects]: pass
case _:
print(f"Sorry, I couldn't understand {command!r}")
match command.split():
# ^ conditional
case ["north"] | ["go", "north"]:
# ^ conditional
current_room = current_room.neighbor("north")
case ["get", obj] | ["pick", "up", obj] | ["pick", obj, "up"]:
# ^ conditional
pass
match = 2
# ^ variable
match, a = 2, 3
# ^ variable
match: int = secret
# ^ variable
x, match: str = 2, "hey, what's up?"
# <- variable
# ^ variable
|