-3
dictFloat = {'1':110.25,'2':0.25,'3':50.50,'4':250.25}

I need to get the value 250.25 from the dictionary and get the key 4

yesuuh
  • 1
  • 1

1 Answers1

0

If you get the dictionary items as tuples, and swap the order of the pair, you can rely on the built-in tuple collation rules, that will consider (a1,b1) > (a2,b2) if a1 > a2:

max((v,k) for k,v in dictFloat.items())
# (250.25, '4')
Rodrigo Rodrigues
  • 7,545
  • 1
  • 24
  • 36