-
Notifications
You must be signed in to change notification settings - Fork 0
/
house.py
49 lines (39 loc) · 1.14 KB
/
house.py
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
## Housing from Harry Potter based on name
name = input("What's your name? ")
# if name == "Harry":
# print("Gryffindor")
# elif name == "Hermione":
# print("Gryffindor")
# elif name == "Ron":
# print("Gryffindor")
# elif name == "Draco":
# print("Slytherin")
# else:
# print("Who?")
## Another approach
# if name == "Harry" or name == "Hermione" or name == "Ron":
# print("Gryffindor")
# elif name == "Draco":
# print("Slytherin")
# else:
# print("Who?")
# ## Using the 'match' statement
# match name:
# case "Harry":
# print("Gryffindor")
# case "Hermione":
# print("Gryffindor")
# case "Ron":
# print("Gryffindor")
# case "Draco":
# print("Slytherin")
# case _: # The ' - ' allows to consider any name for this case to then print "Who?" if their names do not belong to the ones defined above
# print("Who?")
## Integrating the '|' as the or statement to condense the code above
match name:
case "Harry" | "Hermione" | "Ron":
print("Gryffindor")
case "Draco":
print("Slytherin")
case _:
print("Who?")