0

Trying to get the highest value of a letter is kind of hard. When trying this, I get as a result the letter 'z'. How can I make it that it will return 'y' as the highest value?

Here's what I tried:

modes = {'x': 73, 'y': 2179, 'z': 173}
print(max(modes))

Result:

z
jonrsharpe
  • 115,751
  • 26
  • 228
  • 437
Opgesy
  • 103
  • 1
  • 1
  • 7
  • max is getting no information at all about the values in the dictionary, just the keys. Maybe read up on the key argument. – jonrsharpe Jun 17 '22 at 13:35

1 Answers1

2

You can achieve that using the key argument:

 max(modes, key=lambda k: modes[k])
omer.hazan
  • 129
  • 2