I'm trying find the index of the first element bigger than a threshold, like this:
index = 0
while timeStamps[index] < self.stopCount and index < len(timeStamps):
index += 1
Can this be done in a one-liner? I found:
index = next((x for x in timeStamps if x <= self.stopCount), 0)
I'm not sure what this expression does and it seems to return 0 always... Could somebody point out the error and explain the expression?