1 from collections import defaultdict
2 data = [(2010, 2), (2009, 4), (1989, 8), (2009, 7)]
3 d = defaultdict(list)
4print (d) # output --> defaultdict(<type 'list'>, {})
5 for year, month in data:
6 d[year].append(month)
7print (d) # output --> defaultdict(<type 'list'>, {2009: [4, 7], 2010: [2], 1989: [8]})
1#Python Dictionary only contain one key : one value pair.
2#You can surely have multiple keys having same value
3#Example :-
4 dict = {'a':'value1', 'b':'value2', 'c':'value 3'}
5#In above we have a and b key having same values
1No, each key in a dictionary should be unique.
2You can’t have two keys with the same value.
3Attempting to use the same key again will just overwrite the previous value stored.
4If a key needs to store multiple values,
5then the value associated with the key should be a list or another dictionary.
6Sourece: https://discuss.codecademy.com/t/can-a-dictionary-have-two-keys-of-the-same-value/351465