board = [" " for i in range(9)]
def print_board():
row1 = "|{}|{}|{}|".format(board[0], board[1], board[2])
row2 = "|{}|{}|{}|".format(board[3], board[4], board[5])
row3 = "|{}|{}|{}|".format(board[6], board[7], board[8])
print()
print(row1)
print(row2)
print(row3)
print()
def player_move(icon):
if icon == "X":
num = 1
elif icon =="O":
num = 2
print("your turn player {}".format(icon))
choice = int(input("Enter your move(1-9):").strip())
if board[choice - 1]== " ":
board[choice -1]= icon
else:
print()
print("That space is taken!")
print("choose another move")
board[choice - 1] = icon
while True:
print_board()
player_move("X")
print_board()
player_move("O")