I've read two questions about exchange keys with values in a dictionary: Python: Best Way to Exchange Keys with Values in a Dictionary?; How to swap keys for values in a dictionary?.
The best mothod promoted is:
dict((v,k) for k,v in d.items())
However, if a dictionary like this:
d = {"one":1, "two":2, "a":1}
the mothed gets the swapped dictionary:
{1: 'one', 2: 'two'}
The item (1:'a') gets lost. So how can I get a dictionary like this {1: ('one', 'a'), 2: 'two'}? Thanks.