I’ve got something dict like that:
{'Y': [1, 2, 6, 7],
'X': [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24],
'Z': [0, 3, 6, 9]}
There could be more than 3 variables.
I wan’t to get all combination of these variables.
To get something like:
[{'Y': 1, 'X': 0, 'Z': 0},
{'Y': 1, 'X': 0, 'Z': 3} ....]
I can’t figure algorithm for that.
Please help me.
The other posters are right:
itertools.productis very helpful here. However, some care will be needed to ensure you get the original dictionary keys, because of the way your dictionary is formatted.