[Solved] Find the lowest value in dict [closed]


The one-line answer using the min function with personalized key would be

min(chars_dict, key=lambda(item): chars_dict[item]['hp'])

I think it’s the best solution, because you want to find the element with the lowest 'hp'.

Also, if you’re using dictionaries as containers with constant keys, it may be better to use custom classes. And if the keys in the dict are ascending by 1, you may as well use a list.

1

solved Find the lowest value in dict [closed]