input: Write a function to develop a Tic Tac Toe game in Python that includes functions to print the board, manage player turns, check for a win condition, and run the main game loop. The game should allow two players to take turns and inform them of the result if they win or if the game ends in a tie.
  assert main()  # This will initiate the game and should run without errors.
output: def main():
      board = [[' ' for _ in range(3)] for _ in range(3)]
      current_player = 'X'
      
      def print_board():
          for row in board:
              print('|'.join(row))
              print('-' * 5)
      
      def check_win():
          for row in board:
              if row[0] == row[1] == row[2] != ' ':
                  return True
          for col in range(3):
              if board[0][col] == board[1][col] == board[2][col] != ' ':
                  return True
          if board[0][0] == board[1][1] == board[2][2] != ' ':
              return True
          if board[0][2] == board[1][1] == board[2][0] != ' ':
              return True
          return False
      
      def check_tie():
          return all(cell != ' ' for row in board for cell in row)
      
      def switch_player():
          nonlocal current_player
          current_player = 'O' if current_player == 'X' else 'X'
      
      def get_move():
          while True:
              try:
                  move = int(input(f"Player {current_player}, enter your move (1-9): ")) - 1
                  row, col = divmod(move, 3)
                  if board[row][col] == ' ':
                      return row, col
                  else:
                      print("Cell already taken, try again.")
              except (ValueError, IndexError):
                  print("Invalid input, try again.")
      
      while True:
          print_board()
          row, col = get_move()
          board[row][col] = current_player
          
          if check_win():
              print_board()
              print(f"Player {current_player} wins!")
              break
          if check_tie():
              print_board()
              print("It's a tie!")
              break
          
          switch_player()