forked from realpython/materials
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsemaphore.py
More file actions
29 lines (21 loc) · 665 Bytes
/
Copy pathsemaphore.py
File metadata and controls
29 lines (21 loc) · 665 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
27
28
29
from enum import Enum
class Semaphore(Enum):
RED = 1
YELLOW = 2
GREEN = 3
# def handle_semaphore(light):
# if light is Semaphore.RED:
# print("You must stop!")
# elif light is Semaphore.YELLOW:
# print("Light will change to red, be careful!")
# elif light is Semaphore.GREEN:
# print("You can continue!")
def handle_semaphore(light):
match light:
case Semaphore.RED:
print("You must stop!")
case Semaphore.YELLOW:
print("Light will change to red, be careful!")
case Semaphore.GREEN:
print("You can continue!")
handle_semaphore(Semaphore.YELLOW)