I have created a dict in python and would like to find the max value. I experimented with max with key= anonymous function. I certainly implemented wrong, but somehow the code ran and I ended up with output of a key, which does not make sense to me at all. Could you someone please explain to me why it works and how? Thank you.
Q['state1']={'zone':20,'left':50,'right':89,'forward':34}
qmax=max(Q['state1'],key=lambda x: x[1]) %this returns 'forward'
qmax=max(Q['state1'],key=lambda x: x[0]) %this returns 'zone'