I am very simply trying to refer to the value of the previous item when using the enumerate function in Python. I don't know the syntax and cannot find it online. Help much appreciated. Thanks.
#if the close price is > line_price, and the previous is < line_price, then increment broken_line_count
mylist = [6000,6000,6000,6200,6200]
line_price = 6100
broken_line_count = 0
for i, x in enumerate(mylist):
if x>line_price and [i-1](x)<line_price:
broken_line_count +=1
print(broken_line_count)
Obviously [i-1](x)
is incorrect, this is just illustrative of what i'm trying to achieve.