-
Notifications
You must be signed in to change notification settings - Fork 0
/
warmUp-tic-tac-toe.py
38 lines (32 loc) · 1.03 KB
/
warmUp-tic-tac-toe.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
def display_game(game_list):
print("Here is the current list: ")
print(game_list)
def position_choice():
choice = 'WRONG'
while choice not in ['0','1','2']:
choice = input("Pick a position (0,1,2): ")
if choice not in ['0','1','2']:
print('Sorry Invalid Choice!')
return int(choice)
def replacement_choice(game_list, position):
user_placement = input("Type a string to place at position: ")
game_list[position] = user_placement
return game_list
def gameon_choice():
choice = 'WRONG'
while choice not in ['Y', 'N']:
choice = input("Keep Playing? (Y or N): ")
if choice not in ['Y', 'N']:
print('Sorry I did not understand, please choose Y or N ')
if choice == 'Y':
return True
else:
return False
game_on = True
game_list = [0,1,2]
while game_on:
display_game(game_list)
position = position_choice()
game_list = replacement_choice(game_list,position)
display_game(game_list)
game_on = gameon_choice()