The start() is for reference use later for my code.
import os
import random
import time
import replit
playing = ['player1', 'player2']
space = ['1', '2', '3', '4', '5', '6', '7', '8', '9']
def draw():
print('\n ',space[0],'|',space[1],'|',space[2],' ')
print(' ---+---+---')
print(' ',space[3],'|',space[4],'|',space[5],' ')
print(' ---+---+---')
print(' ',space[6],'|',space[7],'|',space[8],'\n')
def ask(prompt):
ask = input(prompt)
return ask
def start():
pick = input('Who go first X / O\n>> ') #this is for reference later
if pick == 'X' or pick == 'x':
print('selected X')
time.sleep(1)
replit.clear()
draw()
play(ask('Choose number\n>> '))
def play(ans):
if ans == 1:
space[0] = 'X'
elif ans == 2:
space[1] = 'O'
draw()
start()
print(space[0])
All of the functions are working properly they are executing fine except for the play() inside it the space[0] = 'X' is not happening, why is that?