input: 
  def transpose(A):
      """ Transpose a given 2D array A and store the result in a new array.
      The function should iterate through the elements of the input array, swapping their
      row and column indices to achieve the transpose.
      >>> transpose([[1, 2, 3], [4, 5, 6]])
      [[1, 4], [2, 5], [3, 6]]
      >>> transpose([[1, 2], [3, 4], [5, 6]])
      [[1, 3, 5], [2, 4, 6]]
      >>> transpose([[1]])
      [[1]]
      """
      n = len(A)
      m = len(A[0])
  
      B = [[0 for x in range(n)] for x in range(m)]
  
      for i in range(n):
          for j in range(m):
              B[j][i] = A[i][j]
  
      return B
  
output:     n = len(A)
      m = len(A[0])
  
      B = [[0 for x in range(n)] for x in range(m)]
  
      for i in range(n):
          for j in range(m):
              B[j][i] = A[i][j]
  
      return B