I need to find what element of apple
has the minimum size
.
Tnx for all answers. But there is one problem: I use Python 2.4.2 (I can't change it) and function min
haven't key
arg. Yes, I need key of apple
apple = {1:{'size':12,'color':'red'},2:{'size':10,'color':'green'}}
Python has a very nice parameter for the
min
function that allows using an arbitrary function to be minified instead of just using comparison on the elements:The
key
parameter replaced in most cases the older idiom of decorate-process-undecorate that could have been applied here:If instead you want to know the number (key) of the apple (it's not clear in the question) then:
or (old style)