So I have a list of string lists
[['a','b'],['c','d'],['e','f']]
and I want to get all the possible combinations, so the result
[['a','b'],['c','d'],['e','f'], ['a','b','c','d'],['a','b','e','f'],['c','d','e','f'], ['a','b','c','d','e','f']]
So far I have found this piece of code
input = [['a','b'],['c','d'],['e','f']] combs = [] for i in xrange(1, len(input)+1): els = [x for x in itertools.combinations(input, i)] combs.extend(els) print combs
mostly after responding to this post .
But this leads to
[(['a','b'],),(['c','d'],),(['e','f'],), (['a','b'],['c','d']),(['a','b'],['e','f']),(['c','d'],['e','f']), (['a','b'],['c', 'd'],['e', 'f'])]
and I'm currently a dead end trying to find an elegant, pufonic way to unpack these tuples.