I have got a list of y coordinates values in grasshopper, which I want to use the Expression (If command) to insert “A” in y coordinates list whenever one of the y coordinates values is bigger than its previous value plus 3.
So it basically means if Y(i+1)>Y(i)+3 then insert A

It seems like adding those tiny little multiplication symbols (*) does the trick.

Plus you need to have valid input for each variable in order to benefit from the realtime sanity check saying what’s wrong with the formula, or when it’s OK.

In your case, there’s no big difference between before & after if you don’t flip your original curve direction.
Another curve which has more sine_curve like shape shows the difference clearly.

Thanks for your response. But unfortunately, it seems like adding the multiplier sign actually multiplies the value of y by i.
But what I am looking for is that it checks the second y coordinate and compare it to the value of the first one plus 3, if the value was bigger then insert A to the list. and if it wasn’t, it inserts B. And continues doing this comparison between the third fourth and so on…
So by “i” in here i mean the number of the index (first y coordinate, second y coordinate and so on…).
However, in the picture you are showing, it is multiplying y with the i + 1 value and comparing it to Y multiplied by i summed up by 3.

#loop through the y component list
for i in range(len(y)): #check if current value is larger than previous+3 #if so, then add A to list
if y[i] > y[i-1]+3 and i>0:
list.append(A) #if not, keep the original value
else:
list.append(y[i])
[/code]

Thank you very much. That works very well.
I have another problem as well. I tried to develop the script that you sent. but I have two problems.

This time I am trying to get the python script to loop through both y and x coordinates values. Then check if current values (of both x and y) are larger than their previous values +3 ( if y[i] > y[i-1]+3 or x[i] > x[i-1]+3 and i>0) then add A to the list.

If not, I want the script to write G1 x value y Value E value (for example G1 X90.585 Y119.095 E0.52988) Or (G1 X[i] Y[i] E)