I'm just starting with the python programming and trying Tic Toc game but I am getting choice is not defined error. My code is as follows://////////////////////////////////////////////////////////////////////////
board = [' ']*10
from IPython.display import clear_output
def display_game(board):
clear_output()
print(' _'+' '+'_'+' '+'_')
print('|'+board[7]+'|'+board[8]+'|'+board[9]+'|')
print('|'+'-'+'|'+'-'+'|'+'-'+'|')
print('|'+board[4]+'|'+board[5]+'|'+board[6]+'|')
print('|'+'-'+'|'+'-'+'|'+'-'+'|')
print('|'+board[1]+'|'+board[2]+'|'+board[3]+'|')
print('|'+'_'+' '+'_'+' '+'_'+'|')
def my_choice():
choice = 'wrong'
while choice not in ['X','O']:
choice = input('Do you want to be X or O?')
if choice not in ['X', 'O']:
print('Sorry, wrong input! Please try again!')
return choice
def choose_pos():
choose = 'wrong'
while choose not in ['1','2','3','4','5','6','7','8','9']:
choose = input('Which place you want to choose from 1 to 9 ')
if choose not in ['1','2','3','4','5','6','7','8','9']:
print('Sorry, wrong input! Please try again!')
# else:
#board[choose] = choice
return choose
def display_update(choice,choose):
board[choose] = choice
display_game(board)
my_choice()
choose_pos()
display_update(choice,choose)
display_game(board)