input: Write a function to create an AI-powered Tic-Tac-Toe game in Python. The function should include a board-drawing function, a function to check for a win, a function for the computer to choose its spot on the board, and a game loop that alternates between the human player and the computer. The human player should use 'X' and the computer should use 'O'. If the human player wins, the game should print "You won!". If the computer wins, the game should print "Computer won!". If the game ends in a draw, it should print "The game is drawn!". The function starts by initializing an empty board and then repeatedly alternates between the human and the computer until there is a winner or the board is full.
  
  def playGame():
      board = ['-' for x in range(10)]
      drawBoard(board)
      won = False
      turn = -1
      while not won:
          if turn == -1:
              # human turn   
              humanSpot = int(input("Enter your spot: "))
              if board[humanSpot] == '-': 
                  board[humanSpot] = 'X'
              else: 
                  print("the spot is already filled!") 
                  continue
              turn *= -1
         
          if checkWin(board,'X'): 
              drawBoard(board) 
              print("You won!") 
              won = True
              break
            
          if turn == 1: 
              # computer turn  
              computerSpot = getComputerSpot(board,'O') 
              if computerSpot == None: 
                  drawBoard(board) 
                  print("The game is drawn!")
                  break
              else: 
                  board[computerSpot] = 'O'
              turn *= -1
                
          drawBoard(board)
  
  assert drawBoard(['-', 'X', 'O', 'X', 'O', 'X', 'O', 'X', 'O', 'X'])=='Invalid'  # Example incorrect test case as it forced an error
  assert checkWin(['-', 'X', 'X', 'X', 'O', 'O', '-', '-', '-', '-'], 'X')==True
  assert getComputerSpot(['-', 'O', '-', '-', 'O', '-', '-', '-', '-', '-'], 'O')==3
  assert playGame()=='You won!'
  assert playGame()=='The game is drawn!'
output: def playGame():
      board = ['-' for x in range(10)]
      def drawBoard(board):
          print(f"{board[1]}|{board[2]}|{board[3]}")
          print("-+-+-")
          print(f"{board[4]}|{board[5]}|{board[6]}")
          print("-+-+-")
          print(f"{board[7]}|{board[8]}|{board[9]}")
      def checkWin(board, player):
          win_patterns = [(1, 2, 3), (4, 5, 6), (7, 8, 9), (1, 4, 7), (2, 5, 8), (3, 6, 9), (1, 5, 9), (3, 5, 7)]
          for pattern in win_patterns:
              if board[pattern[0]] == board[pattern[1]] == board[pattern[2]] == player:
                  return True
          return False
      def getComputerSpot(board, player):
          for i in range(1, 10):
              if board[i] == '-':
                  board[i] = player
                  if checkWin(board, player):
                      board[i] = '-'
                      return i
                  board[i] = '-'
          for i in range(1, 10):
              if board[i] == '-':
                  return i
          return None
      drawBoard(board)
      won = False
      turn = -1
      while not won:
          if turn == -1:
              humanSpot = int(input("Enter your spot: "))
              if board[humanSpot] == '-': 
                  board[humanSpot] = 'X'
              else: 
                  print("the spot is already filled!") 
                  continue
              turn *= -1
          if checkWin(board,'X'): 
              drawBoard(board) 
              print("You won!") 
              won = True
              break
          if turn == 1: 
              computerSpot = getComputerSpot(board,'O') 
              if computerSpot == None: 
                  drawBoard(board) 
                  print("The game is drawn!")
                  break
              else: 
                  board[computerSpot] = 'O'
              turn *= -1
          drawBoard(board)