Advertisement
Guest User

Python 3: zip() is its own inverse!

a guest
Sep 14th, 2020
119
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.36 KB | None | 0 0
  1. Python 3.9.0rc1 (default, Aug 12 2020, 00:00:00)
  2. [GCC 10.2.1 20200804 (Red Hat 10.2.1-2)] on linux
  3. Type "help", "copyright", "credits" or "license()" for more information.
  4. >>> l1 = list(zip(*[('a', 1), ('b', 2), ('c', 3), ('d', 4)]))
  5. >>> l1
  6. [('a', 'b', 'c', 'd'), (1, 2, 3, 4)]
  7. >>> l2 = list(zip(*l1))
  8. >>> l2
  9. [('a', 1), ('b', 2), ('c', 3), ('d', 4)]
  10. >>>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement