-4

I'm catching up with Python3 so I hope I can get some slack :P I have a list of lists, say:

results=[[1, 5000],
 [2, 5000],
 [3, 6666],
 [4, 6250],
 [5, 6000],
 [6, 5833],
 [7, 5714],
 [8, 6250],
 [9, 6111]]

And I would like to get the entry which has the biggest second value (in this case, the pair [3, 6666]).

Could I have some quick reference on how to get it?

Thanks!

ggonmar
  • 760
  • 1
  • 7
  • 28
  • This community isn't a "do all the work for you" service, it's more to help you get unstuck from a specific problem with code. You can't show zero effort and expect a full answer. – Random Davis Sep 14 '20 at 16:02

1 Answers1

2

Here is one approach using itemgetter()

import operator
 
>>> max(results, key=operator.itemgetter(1))
[3, 6666]
>>> 

Tibebes. M
  • 6,940
  • 5
  • 15
  • 36