In the program I need to write a function that takes the player's input for where they want to place the 'X' or 'O' for the Tic Tac Toe game, which would be a number between 0-8 and the function would also recognise invalid responses. An invalid response would be a number not between 0-8, anything that is not a number or a number that has been inputted previously.
What is the problem?
No matter what the input is the function recognises it as invalid, even if it should be valid.
Here is the code
def playerinput():
print("Select the number on the board:")
while True:
playerchoice = input()
if playerchoice.isdigit == True:
if int(playerchoice) in validdata:
validdata.pop(int(playerchoice))
return int(playerchoice)
else:
print("That is not a valid input please enter a different value:")
else:
print("That is not a valid input please enter a different value:")
validdata is a global variable
validdata = [0,1,2,3,4,5,6,7,8]