>>> d = {'a': [1, 2], 'b': [4, 5], 'c': [7, 8]}
You can access the key, value pairs using dict.items()
.
>>> list(d.items())
[('a', [1, 2]), ('c', [7, 8]), ('b', [4, 5])]
Then you can iterate over the pairs and iterate over the list values:
>>> [(key, value) for (key, values) in d.items()
... for value in values]
[('a', 1), ('a', 2), ('c', 7), ('c', 8), ('b', 4), ('b', 5)]
The dictionary keys are not ordered alphabetically. If you want the exact output in your question you need to sort them, either before creating your list or after:
>>> pairs = _
>>> sorted(pairs)
[('a', 1), ('a', 2), ('b', 4), ('b', 5), ('c', 7), ('c', 8)]