i'm trying to iterate over an arraylist saving in every loop the highest/lowest difference of the consecutive values.
e1=([ 0 , 0, 0, 0, 15, 28, 28, 28, 27, 27, 35, 44, 43, 43, 42, 39]) Hodiffmax = 0 Hodiffmin = 0 for k in e1: diff1= e1[k+1] - e1[k] if diff1 > Hodiffmax: Hodiffmax=diff1 if diff1 < Hodiffmin: Hodiffmin=diff1
The problem is i get an "index out of bound" error. How can i iterate through an arraylist with [k+1]? I tried a bunch of things now but i dont get smarter. I appreciate any help!
EDIT (that works neither):
for k in e1: for w in k: diff1= e1[w+1] - e1[w] if diff1 > Hodiffmax: Hodiffmax=diff1 if diff1 < Hodiffmin: Hodiffmin=diff1
Error: for w in k - TypeError: 'numpy.int32' object is not iterable