How to retrieve the keys of duplicate list-values?
d1 = {'a': ['abc','cde','abc'], 'b': ['a', 'd', 'f'], 'c': ['abc','cde','abc']}
Expected output: ['a','c']
or {'a':'c'}
.
I tried this code:
from collections import Counter
d1 = {1: [1], 2: [1, 2]}
Counter([r[1] for r in d1.items()])
But I get an error:
TypeError: unhashable type: 'list'
I also tried with Counter(d1.values())
, but get the same error.
Is this the right approach? Or is there a better way?