Having the following dictionary:
d = {
'a': [1, 2, 3],
'b': [True, False]
}
How can I generate a list of dictionaries representing all combinations of the values for each key? The output should be like this:
combinations = [
{'a': 1, 'b': True},
{'a': 2, 'b': True},
{'a': 3, 'b': True},
{'a': 1, 'b': False},
{'a': 2, 'b': False},
{'a': 3, 'b': False}
]
This should work with an arbitrary number of keys and an arbitrary length of values in the dictionary. We can assume that the values are always a list.