input: Write a function to play a game of Tic-Tac-Toe against an AI using Python. The function should allow the user to input their move, and then the AI should determine and place its move accordingly. If the board is empty, the AI should choose a spot randomly. If there is a winning move for the AI, it should place its move to win. The game should display the board after each move and announce the winner or if the game is a draw. If the board is full and no winner is determined, the game should end in a draw.
  assert playGame() == None
  assert playGame() == None
  assert playGame() == None
  assert playGame() == None
  assert playGame() == None
output: def playGame():
      import random
  
      def print_board(board):
          for row in board:
              print(" | ".join(row))
              print("-" * 5)
  
      def check_winner(board, player):
          for row in board:
              if all([cell == player for cell in row]):
                  return True
          for col in range(3):
              if all([board[row][col] == player for row in range(3)]):
                  return True
          if all([board[i][i] == player for i in range(3)]) or all([board[i][2 - i] == player for i in range(3)]):
              return True
          return False
  
      def is_full(board):
          return all([cell != " " for row in board for cell in row])
  
      def ai_move(board):
          for player in ["O", "X"]:
              for i in range(3):
                  for j in range(3):
                      if board[i][j] == " ":
                          board[i][j] = player
                          if check_winner(board, player):
                              return
                          board[i][j] = " "
          for i in range(3):
              for j in range(3):
                  if board[i][j] == " ":
                      board[i][j] = "O"
                      return
  
      board = [[" " for _ in range(3)] for _ in range(3)]
      current_player = "X"
  
      while True:
          print_board(board)
          if current_player == "X":
              move = input("Enter your move (row, col): ").strip().split(",")
              row, col = int(move[0]), int(move[1])
              if board[row][col] != " ":
                  print("Invalid move, try again.")
                  continue
              board[row][col] = "X"
          else:
              ai_move(board)
  
          if check_winner(board, current_player):
              print_board(board)
              print(f"{current_player} wins!")
              return
  
          if is_full(board):
              print_board(board)
              print("It's a draw!")
              return
  
          current_player = "O" if current_player == "X" else "X"