I've tried flip my dict. If some keys have the same value the flipped dict key should be a set()
d = {'a': 1, 'b': 2, 'c': 3, 'd': 3}
output should be:
{1: 'a', 2: 'b', 3: {'c', 'd'}}
I've tried that:
d = {'a': 1, 'b': 2, 'c': 3, 'd': 3}
rev_dict = {}
for k, v in d.items():
rev_dict.setdefault(v, set()).add(k)
print(rev_dict)
But I got that:
{1: {'a'}, 2: {'b'}, 3: {'c', 'd'}}