Ending test phase after 20 trials

Hello,
In the test phase, I want participants to complete 20 trials among the 150 rows in Excel. Then, if they give accurate answers for 70% of the trials, they can continue to experiment. How can I limit trial numbers by a code? As long as I add an excel sheet to the loop, it runs all the rows in the sheet.

You can do this by adding a Code component with this in the End Routine tab:

if trials.thisRepN >= 20:
    trials.finished = True

Meaning that the loop with terminate after 20 reps

Thank you so much!