My approach with this function is that it only accepts an integer as an input, otherwise if the person enters a letter or something else it goes back to the while loop and continues asking for the input until it receives the correct input which in this case it can only be 1-9.
import string
string.ascii_letters
def player_choice(board):
position = 0
while position not in list(range(1,10)) or space_check(board, position) or position in list[string.ascii_letters]:
if position in list[string.ascii_letters]:
pass
position = int(input("Please enter a position(1-9): "))
return position
I tried importing ascii_letters from the string library to tell python that if the input is inside of the that list to go back to the while loop, but everytime I run the code i get a syntax error saying that the input only accepts an integer.