converting a dictionary to another one

Viewed 1946

I have a dictionary, the keys are integer values and the values are a list of strings. I want to make it vice versa, the string become key and integers become values. Like:

first design:

{1:["a"], 2:["a","b"], 3:["a"], 4:["b", "cd"], 6:["a","cd"]}

second design:

{"a": [1,2,3,6], "b":[2,4], "cd":[4,6]}

any clue? Thanks

6 Answers
Related