I would like to generate all combinations of values which are in lists indexed in a dict:
{\'A\':[\'D\',\'E\'],\'B\':[\'F\',\'G\',\'H\'],\'C\':[\'I\',\'J\']}
If you want to keep the key:value
in the permutations you can use:
import itertools
keys, values = zip(*my_dict.items())
permutations_dicts = [dict(zip(keys, v)) for v in itertools.product(*values)]
this will provide you a list of dicts with the permutations:
print(permutations_dicts)
[{'A':'D', 'B':'F', 'C':'I'},
{'A':'D', 'B':'F', 'C':'J'},
...
]
disclaimer
not exactly what the OP was asking, but google send me here looking for that.