Transpose a Matrix
Easy 20 XPMatrix
Commonly asked at TCS, Zoho
Read r and c, then r rows of c integers. Print the transpose (rows become columns): c rows of r integers.
- Input
- Line 1: r c. Next r lines: c integers each.
- Output
- c lines of r integers.
Sample 1
Input
2 3 1 2 3 4 5 6
Output
1 4 2 5 3 6
Read input with input() (no prompt message) and print only the answer. Run tries the Input box; Submit checks all test cases.
Output Loading Python (first time takes a few seconds)
Press Run to see the result here.The solution unlocks after 3 submissions.