-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcar_game.py
28 lines (26 loc) · 877 Bytes
/
car_game.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
# 6th exercise. simple car game that has 4 functions, start, stop, help, and quit. must exercise while loop
# and if functions effectively.
car_started = False
while True:
command = input("> ").lower()
if command == "help":
print("""start - to start the car
stop - to stop the car
quit - to end the application""")
elif command == "start":
if not car_started:
print("Car has started")
car_started = True
else:
print("Car has already started.")
elif command == "stop":
if car_started:
print("Car has stopped")
car_started = False
else:
print("Car has already stopped.")
elif command == "quit":
print("Thanks for playing!")
break
else:
print("Sorry, I don't understand that. Type 'help' for the available commands.")