-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgame.py
31 lines (25 loc) · 891 Bytes
/
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
29
30
31
def replace(index, items):
replacement = input("What should replace the item? ")
items[int(index)] = replacement
def validate_input(index):
if index not in ["0", "1", "2"]:
print("Not a valid index")
exit()
def should_we_carry_on():
carry_on_choice = input("Would you like to carry on (y / n) ? ")
if carry_on_choice not in ["y", "n"]:
print("I'm sorry, I don't understand your selection. Exiting.")
if carry_on_choice == "y":
return True
else:
return False
def play():
things = ["First", "Second", "Third"]
carry_on = True
while carry_on:
print("The items are:", things)
choice = input("Choose an index of a item to replace (0, 1 or 2) ? ")
validate_input(choice)
replace(choice, things)
print("The new items are:", things)
carry_on = should_we_carry_on()