First Python list index greater than x?
What would be the most Pythonic way to find the first index in a list that is greater than x?
For example, with
list = [0.5, 0.3, 0.9, 0.8]
The function
f(list, 0.7)
would return
2.
next(x[0] for x in enumerate(L) if x[1] > 0.7)
if list is sorted then bisect.bisect_left(alist, value)
is faster for a large list than next(i for i, x in enumerate(alist) if x >= value)
.