input: Write a python function to print elements of a 2D array in spiral order.
  assert spiralPrint([[1, 2, 3], [4, 5, 6], [7, 8, 9]]) == [1, 2, 3, 6, 9, 8, 7, 4, 5]
  assert spiralPrint([[1, 2], [3, 4]]) == [1, 2, 4, 3]
  assert spiralPrint([[1]]) == [1]
output: def spiralPrint(matrix):
      result = []
      while matrix:
          result += matrix.pop(0)  # take the first row
          if matrix and matrix[0]:
              for row in matrix:
                  result.append(row.pop())  # take the last element of each remaining row
          if matrix:
              result += matrix.pop()[::-1]  # take the last row in reverse order
          if matrix and matrix[0]:
              for row in matrix[::-1]:
                  result.append(row.pop(0))  # take the first element of each remaining row in reverse order
      return result