Skip to content

Instantly share code, notes, and snippets.

@FerdinaKusumah
Created December 5, 2019 01:29
Show Gist options
  • Save FerdinaKusumah/a928641c6388b4305561bb576c32a152 to your computer and use it in GitHub Desktop.
Save FerdinaKusumah/a928641c6388b4305561bb576c32a152 to your computer and use it in GitHub Desktop.
Transpose 2d list
"""Transpose 2d list"""
a = [["a", "b"], ["c", "d"], ["e", "f"]]
transposed = zip(*a)
to_list = list(transposed)
print("Transpose list from {} to {}".format(a, to_list))
# Transpose list from [['a', 'b'], ['c', 'd'], ['e', 'f']] to [('a','c', 'e'), ('b', 'd', 'f')]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment