Go-No go test, no more than 3 consecutive No go

I’m doing a Go-No go test of motor inhibition with arrows pointing to the left (Go) and to the right (No go) or vice versa, I’m using the Builder window and the test is about finished (it works without any problem). By running my test in full (30min for about 900 stimuli) I got several times 4 to 5 No go stimuli in a row out of I would like not to exceed 3 consecutive No go at most.
I used a file for my conditions, 5 conditions: 4 Go with the image of an arrow going to the left for 1 No go for the other arrow (see image).
I understood that I will have to use a list or an array to make a counter of the No go and force the appearance of the stimulus Go when I exceed 3 but I can’t manage to write the code with a correct syntax (I’m quite a novice in python, I started only a few weeks ago).
Thanks in advance if you can help me !