python - Finding a tuple with greatest value -


given these 2 lists:

first = [('-2.50', '1.91', '2.03'), ('3.00', '1.83', '2.08')] second = [(('-2.50', 0.889258, 1.069258), ('3.00', 0.931381, 1.021381))] 

it's two-task challenge. firslty, in list second, need identify tuple greatest value in (while values @ position 0 here: -2.50 , 3.00 must ignored). then, second task, need output corresponding tuple form list first. should result in:

('-2.50', '1.91', '2.03') 

this because greatest value found in step first should 1.069258 inside 1st tuple.

the snag face here finding tuple greatest value (i know can use max() find value need whole tuple), 2nd part of problem think i'll cope using if statement.

in 1 line:

>>> max(zip(first,second[0]),key=lambda x:max(x[1][1:]))[0] ('-2.50', '1.91', '2.03') 

Comments

Popular posts from this blog

Perl - how to grep a block of text from a file -

delphi - How to remove all the grips on a coolbar if I have several coolbands? -

javascript - Animating array of divs; only the final element is modified -