How do I retrive the top 3 list from a dictionary?
>>> d {\'a\': 2, \'and\': 23, \'this\': 14, \'only.\': 21, \'is\': 2, \'work\': 2, \'will\': 2, \
>>> d = {'a': 2, 'and': 23, 'this': 14, 'only.': 21, 'is': 2, 'work': 2, 'will': 2, 'as': 2, 'test': 4} >>> t = sorted(d.iteritems(), key=lambda x:-x[1])[:3] >>> for x in t: ... print "{0}: {1}".format(*x) ... and: 23 only.: 21 this: 14