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

c++ - Function signature as a function template parameter -

algorithm - What are some ways to combine a number of (potentially incompatible) sorted sub-sets of a total set into a (partial) ordering of the total set? -

How to call a javascript function after the page loads with a chrome extension? -