Skip to content

Instantly share code, notes, and snippets.

@stlehmann
Created March 31, 2014 20:56
Show Gist options
  • Save stlehmann/9902057 to your computer and use it in GitHub Desktop.
Save stlehmann/9902057 to your computer and use it in GitHub Desktop.
Find all combinations of two lists
>>> import itertools
>>> list_1 = [1, 2, 3]
>>> list_2 = [4, 5, 6]
>>> list(itertools.product(list_1, list_2))
[(1, 4), (1, 5), (1, 6), (2, 4), (2, 5), (2, 6), (3, 4), (3, 5), (3, 6)]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment