Skip to content

Instantly share code, notes, and snippets.

@gchiam
Last active August 29, 2015 14:06
Show Gist options
  • Save gchiam/76601be8a59d28ebcf37 to your computer and use it in GitHub Desktop.
Save gchiam/76601be8a59d28ebcf37 to your computer and use it in GitHub Desktop.
a = [1, 2, 3]
b = [4, 5, 6]
zipped = zip(a,b)
# zipped = [(1, 4), (2, 5), (3, 6)]
unzipped = zip(*zippped)
# unzipped = [(1, 2, 3), (4, 5, 6)]
# get back a, b
a, b = zip(*zipped)
# a = (1, 2, 3)
# b = (4, 5, 6)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment