Skip to content

Instantly share code, notes, and snippets.

@adrianulbona
Last active January 5, 2018 10:14
Show Gist options
  • Save adrianulbona/b4ac4768287d5572217c0a4eeb490da6 to your computer and use it in GitHub Desktop.
Save adrianulbona/b4ac4768287d5572217c0a4eeb490da6 to your computer and use it in GitHub Desktop.
zip/unzip python
numbers = (1, 2, 3)
chars = ('a', 'b', 'c')
numbers_chars = list(zip(numbers, chars))
# [(1, 'a'), (2, 'b'), (3, 'c')]
unzipped_numbers, unzipped_chars = zip(*numbers_chars)
# ((1, 2, 3), ('a', 'b', 'c'))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment