[Tutor] Get max quantity

Carlos carloslara at web.de
Wed Jun 13 19:48:12 CEST 2007


Hello,

If I have a dictionary like:

inventory = {'apples': 430, 'bananas': 312, 'oranges': 525, 'pears': 217}

How can I get the item with the largest quantity? I tried:

max(inventory)

but got:

'pears'

What I would like to get is 'oranges', at least in this case.

Thanks,
Carlos



More information about the Tutor mailing list