Reversing keys and values in a python dict is a bit tricky. You should have in mind that a python dict must have a unique
keys.
So, if you know that when reversing keys and values of your current dict will have a unique keys, you can use a simple dict comprehension
like this example:
{v:k for k,v in my_dict.items()}
However, you can use groupby
from itertools
module like this example:
from itertools import groupby
a = {1:10, 2:20, 3:30, 4:30}
b = {k: [j for j, _ in list(v)] for k, v in groupby(a.items(), lambda x: x[1])}
print(b)
>>> {10: [1], 20: [2], 30: [3, 4]}