Back to Problems
## Transpose of a Matrix (easy)

#### Example

## Transpose of a Matrix

Consider a matrix \(M\) and its transpose \(M^T\), where:
Original Matrix \(M\):
\[
M = \begin{pmatrix}
a & b & c \\
d & e & f
\end{pmatrix}
\]
Transposed Matrix \(M^T\):
\[
M^T = \begin{pmatrix}
a & d \\
b & e \\
c & f
\end{pmatrix}
\]
Transposing a matrix involves converting its rows into columns and vice versa. This operation is fundamental in linear algebra for various computations and transformations.

Write a Python function that computes the transpose of a given matrix.

Example: input: a = [[1,2,3],[4,5,6]] output: [[1,4],[2,5],[3,6]] reasoning: The transpose of a matrix is obtained by flipping rows and columns.

def transpose_matrix(a: list[list[int|float]]) -> list[list[int|float]]: return [list(i) for i in zip(*a)]

Output will be shown here.

Solution copied to clipboard!