I want to create a list of tuples with first element from a list, and the second element from a function of the element of list, then find the minimum from the output of the function. The code below best explains what I want:
x,y = min((x,f(x) for x in array), key = lambda(k, v): v[1])
After running the script, I am getting:
SyntaxError: invalid syntax
NOTE: f(x) returns int/float
I guess you want this:
x,y = min(((x,f(x)) for x in array), key = lambda(k, v): v)