In this article, I’m going to share a scenario wherein we need to get a key from a Python dictionary, which is holding maximum value.
Usually we are required to get a key having maximum key from a dictionary, which, of course, most of us can do very easily. But when it comes to the other way round, it is not that straight forward.
I also found that this is one of the hottest questions these days for interviewers :)
To achieve the scenario of a dictionary key having maximum value, we can go with two different ways as mentioned below:
Method 1: Using itemgetter()
Method 2: Using lambda CODE
You can use any of these methods and you will get the same output.
I hope you enjoyed learning this concept. Do not forget to check out the recording of this article on my YouTube channel:
Comments
Post a Comment