I wanted my variable play
to change whenever the turn changes so I made a function. If turn is even play will be variable O="O", vice versa for odd
then I used the function even(turn) with turn=1, it displays O even though it should be X. Is my code below wrong in some way or it just doesn't work like that?
I'm making a tic tac toe program on repl.it, I've tried using manual change as in making 9 different copies to change the turns but its just too much work, I wanted to make a simpler code.
play=0
X="X"
O="O"
turn=1
def even(turn):
if turn%2==0:
play=O
else:
play=X
even(turn)
print(play)
I expect the output to be either O or X according to if the number is even or odd respectively.