Skip to content

Instantly share code, notes, and snippets.

@pralabhsaxena05
Last active December 10, 2021 07:22
Show Gist options
  • Save pralabhsaxena05/ecd7acf7a9657193aad3afd365b9e038 to your computer and use it in GitHub Desktop.
Save pralabhsaxena05/ecd7acf7a9657193aad3afd365b9e038 to your computer and use it in GitHub Desktop.
matrix = [[1, 2, 3], [4, 5, 6]]
print("Before transpose:")
for row in matrix:
print(row)
#transpose in a single line
transposed_matrix = zip(*matrix)
print("After transpose:")
for row in transposed_matrix:
print(list(row))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment