Python: get the key from dictionary based on minimum value

P

Say we have a dictionary like below:

d={
    "a":23,
    "b":12,
    "c":3,
    "d":6,
    "e":9
}

Now we want to get the key for minimum value.

The Code is:

print(min(d, key=d.get))

About the author

Imran Pollob

Learn => Practice => Implement => Repeat

Add comment

Categories

Imran Pollob

Learn => Practice => Implement => Repeat

Get in touch