fork download
  1. cat = [1, 2, 3], [4, 5, 6], [7, 8, 9]
  2.  
  3. print('CAT:', cat)
  4.  
  5. print('FST:')
  6. print(list(zip(*cat)))
  7. print('EQ:')
  8. print(list(zip(
  9. [1, 2, 3],
  10. [4, 5, 6],
  11. [7, 8, 9]
  12. # ^ ^ ^
  13. #(147)(258)(369)
  14. )))
  15.  
  16. print('SND')
  17. print(list(zip(cat)))
  18. print('EQ:')
  19. print(list(zip(
  20. ([1, 2, 3], [4, 5, 6], [7, 8, 9])
  21. # ( A , B , C )
  22. # >> [ (A,) , (B,) , (C,) ]
  23. )))
Success #stdin #stdout 0.04s 9488KB
stdin
Standard input is empty
stdout
CAT: ([1, 2, 3], [4, 5, 6], [7, 8, 9])
FST:
[(1, 4, 7), (2, 5, 8), (3, 6, 9)]
EQ:
[(1, 4, 7), (2, 5, 8), (3, 6, 9)]
SND
[([1, 2, 3],), ([4, 5, 6],), ([7, 8, 9],)]
EQ:
[([1, 2, 3],), ([4, 5, 6],), ([7, 8, 9],)]