get key of min value 1

get key of min value

>>> d = {320: 1, 321: 0, 322: 3}
>>> min(d, key=d.get)

Here is what the above code is Doing:
1. The min() function takes a key argument, which is a function that takes one argument and returns a value.
2. The key argument is applied to each element of the iterable, and the minimum element is returned.
3. The key function is d.get, which returns the value of the dictionary entry.
4. The minimum value is returned, which is the key 321.

Similar Posts