Transpose a Matrix

easynumpy_basics

Implement transpose_2d(X).

Given a 2D array X of shape (m, n), return its transpose of shape (n, m): the element at position (j, i) of the result equals X[i, j]. No for/while loops.

Constraints
  • no for/while loops

Your solution

Edit transpose_2d and run the real pytest suite in your browser — no install required. Your code is saved locally.

⌘/Ctrl + ↵

Loading the Python runtime (first run only)…

Hints

Hint 1

X.T (or np.transpose(X)) swaps the two axes of a 2D array.