I'm on my first Python project trying to create a tic-tac-toe game. I have a question regarding while loop logic. So I have a player input function, whereby the player decides what marker (X or O) in tic-tac-toe they would like to play with.
My function is as follows:
def player_input():
marker = ''
while marker != 'X' or marker != 'O':
marker = input('Player 1 choose X or O ').upper()
if marker == 'X':
return ('X','O')
else:
return ('O','X')
The result is the while loop continues to ask the user the question even if they give the correct input ('X' or 'O')
However, upon checking the solution, this modification to the while loop statement returns the tuple corresponding to the marker the user entered:
while not (marker == 'X' or marker == 'O'):
I don't understand how this works, From my perspective I have written the exact same thing above in the player_input
function, am I missing something really obvious?