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