def startGame(player_score, computer_score): game = TicTacToe() print(f'Player wins: {player_score}\tComputer wins: {computer_score}') isWinner = False error = False while not isWinner: if error is False: game.displayBoard() else: print('\nInvalid coordinates\n') coords = input('Enter coordinate: ') if game.validateCoordinates(coords): error = False coordinates = coords.split(' ') game.setPosition(coordinates[0], coordinates[1], 'X') game.setComputerPosition() if game.checkWinner() == 'X': player_score += 1 isWinner = True game.displayBoard() print('\nPlayer Wins!\n') elif game.checkWinner() == 'O': computer_score += 1 isWinner = True game.displayBoard() print('\nComputer Wins!\n') elif game.checkWinner() == 'T': isWinner = True game.displayBoard() print('\nThe Game was a Tie!\n') else: continue else: error = True while True: print('Would you like to play again?') print('[1] Yes') print('[2] No') choice = input('Enter: ') if choice == '1': print('\n') startGame(player_score, computer_score) elif choice == '2': print('\nThank you for playing\n') exit() else: print('\nInvalid choice picked\n')