Reputation: 7916
It's a horrible title, I know; the basic explanation of what I mean is:
y=min([func(x) for x in range(z)])
As is, y
contains the value of the output of func(x_min)
. (x_min
might not actually be the smaller value in the range).
Basically, I'm looking for a way to get x_min
in this generic case in a more pythonic way. Any ideas?
UPDATE: From SilentGhosts answer, (RTFM...), the equivalent of the above would be;
x_min=min(range(z),key=func)
Upvotes: 0
Views: 88