You don’t need to know n
in advance to use itertools.product
>>> import itertools
>>> s=[ [ 'a', 'b', 'c'], ['d'], ['e', 'f'] ]
>>> list(itertools.product(*s))
[('a', 'd', 'e'), ('a', 'd', 'f'), ('b', 'd', 'e'), ('b', 'd', 'f'), ('c', 'd', 'e'), ('c', 'd', 'f')]
More Related Contents:
- Is there a way to ordinate numbers in a list?
- finding the biggest sequence of repeating numbers in a list
- How to append new line to the list
- Find intersection of two nested lists?
- Remove duplicate dict in list in Python
- How to efficiently compare two unordered lists (not sets) in Python?
- Finding max value in the second column of a nested list?
- Why does foo.append(bar) affect all elements in a list of lists?
- list to dictionary conversion with multiple values per key?
- How to get the nth element of a python list or a default if not available
- Python – TypeError: ‘int’ object is not iterable
- How do I split a string into a list?
- Why doesn’t list have safe “get” method like dictionary?
- Explicitly select items from a list or tuple
- How do I prepend to a short python list?
- Python: why does my list change when I’m not actually changing it?
- Does python have a sorted list?
- Summing elements in a list
- “unstack” a pandas column containing lists into multiple rows [duplicate]
- Break string into list of characters in Python [duplicate]
- How to make a custom object iterable?
- How to access the elements of a 2D array?
- Why does a for-loop with pop-method (or del statement) not iterate over all list elements [duplicate]
- How to create a list of objects?
- Why does using multiplication operator on list create list of pointers? [duplicate]
- Remove dictionary from list
- Determine if 2 lists have the same elements, regardless of order? [duplicate]
- How do I extract all the values of a specific key from a list of dictionaries?
- Iterate through adjacent pairs of items in a Python list [duplicate]
- Python The appended element in the list changes as its original variable changes