I have a problem. In my code, I have the following dictionary:
{1: {'amount': 40.0, 'quantity': 0}, 2: {'amount': 40.0, 'quantity': 0}, 3: {'amount': 40.0, 'quantity': 0}, 4: {'amount': 40.0, 'quantity': 0}, 5: {'amount': 41, 'quantity': 0}, 6: {'amount': 40.0, 'quantity': 0}, 7: {'amount': 40.0, 'quantity': 0}, 8: {'amount': 40.0, 'quantity': 0}, 9: {'amount': 40.0, 'quantity': 0}, 10: {'amount': 40.0, 'quantity': 0}}
Out of this dictionary, I need to grab the key of the inner dictionary with the greatest amount. In my case, that should be 5. I found a lot about things like this, but nothing about nested dictionaries.
I came up with something like this:
max(int(i['amount']) for i in dict.values())
But this returns the highest amount. I need to return the key of that dictionary with that amount. How can I achieve what I want?