I have the following, where the value for each key is a dictionary itself:
dict = { "key1": { "sal":24000, "xy":32, "age":54}
"key2": { "sal":40000, "xy":22, "age":14}
"key3": { "sal":50000, "xy":12, "age":64} }
I want to extract the maximum and minimum salary from here. i.e my output should be 24000 when I search for the minimum and 50000 when I search for the maximum.
How do I go about this? Thank you.
max(dict.itervalues(), key=lambda x: x['sal'])
Just the same for minimum.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With