def confirm_board_size():
print()
num = input("What size board would you like to play on? 3, 4, or 5: ")
while num not in range(3, 6):
try:
num = int(num)
except ValueError:
print(f"{num} is not a valid input. Please enter 3, 4, or 5.")
confirm_board_size()
else:
if num not in range(3, 6):
print(f"{num} is not a valid input. Please enter 3, 4, or 5.")
confirm_board_size()
sample_board = Board(num)
sample_board.create_board()
sample_board.show_board()
confirm = input("You will be playing on this board. Is that OK? ")
confirm = confirm.lower()
if confirm == 'y':
return int(num)
else:
confirm_board_size()
I ran this code through a debugger. On the first call to the confirm_board_size function if the confirm variable is anything other than 'y', the function gets called again and asks for the relevant inputs and those all get overwritten. However, when the confirm variable's input call comes up again and I enter input, the confirm variable remains the same and the confirm_board_size function returns a None value and exits. Why is this occurring? I'm using Python 3.11.3