I have an array and function and I would like the function to return a list of indices in which the difference of two consecutive elements passes a threshold.
I have:
def func (y, t=100):
for i in range(1, len(y)): #Range skips 1st element
if abs(y[i] - y[i-1]) > t:
return(i)
The problem I'm facing is that this function only returns the first index where my if statement is true. How do I get the rest of them?
yield iand collect items in alist(In other words convert your function to a generator function)