Skip to content

Instantly share code, notes, and snippets.

@Nurdok
Created July 13, 2012 22:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Nurdok/3107976 to your computer and use it in GitHub Desktop.
Save Nurdok/3107976 to your computer and use it in GitHub Desktop.
Double Iteration in List Comprehension
>>> seq_x = [1, 2, 3, 4]
>>> seq_y = 'abc'
>>> [(x,y) for x in seq_x for y in seq_y]
1: [(1, 'a'),
(1, 'b'),
(1, 'c'),
(2, 'a'),
(2, 'b'),
(2, 'c'),
(3, 'a'),
(3, 'b'),
(3, 'c'),
(4, 'a'),
(4, 'b'),
(4, 'c')]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment