Skip to content

Instantly share code, notes, and snippets.

@aaronshaver
Created April 20, 2022 23:46
Show Gist options
  • Save aaronshaver/5ed7c9f4e0a5dfce9d592fb49b7e004a to your computer and use it in GitHub Desktop.
Save aaronshaver/5ed7c9f4e0a5dfce9d592fb49b7e004a to your computer and use it in GitHub Desktop.
Get all combinations of a list of lists using itertools.product
import itertools
sets = [['a', 'b', 'c'], ['d', 'e', 'f'], ['g', 'h', 'i']] # lists do not have to be of equal size
combinations = list(itertools.product(*sets))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment