Why is the console giving me 'to' as the output whereas it should be 'semynak'?

I was making a program where I need to used this piece of code.
HERE IS THE CODE

dict = {‘take’: 37, ‘me’: 18, ‘to’: 35, ‘semynak’: 88}
print(max(dict))
to

The issue is that why is this coming ‘to’. It should be ‘semynak’?

Every suggestion will be appreciated.

THANK YOU

the alphabet: abcdefghijklmnopqrstuvwxyz

t is most certainly after s, so to makes perfect sense.

1 Like

So what can I do so that I get the output as ‘semynak’ as it’s value is the highest?

so that is went wrong, calling max() directly on dictionary will look at the keys, not the values

max can take a key argument:

https://docs.python.org/3/library/functions.html#max

you could use this to tell the max function what key to use for comparison (in this case, the values of the dictionaries), as explained here:

https://stackoverflow.com/questions/268272/getting-key-with-maximum-value-in-dictionary