I want to trigger a response at different points in a loop
<p>I have created a task on Psychopy in which beads a drawn from a jar. 50 different beads are drawn and after each bead the participant is asked to make a probability rating. The task is looped from an excel file but it takes too long to do 50 ratings. I was hoping to get ratings for the first 10 beads. Then draw up a rating for ever second bead until 20 beads are drawn. Then for the next 30 beads until the 50th bead to only ask for a rating every five beads drawn (I'm really new to coding, sorry for how incorrect this may be in advance). 
I've written the code like this however unfortunately it doesn't work? (on the turns that don't have a rating i've tried to put a keyboard response to trigger the next thing in the sequence to emerge) -</p>

<pre><code>for row_index, row in (beads_params_pinkbluegreyratingparamters.xlsx):
if row(0:10) and t &gt;= 0.0 and rating.status == NOT_STARTED:
    break
    rating.tStart = t  # underestimates by a little under one frame
    rating.frameNStart = frameN  # exact frame index
    rating.setAutoDraw(True)
 continueRoutine &amp;= rating.noResponse # a response ends the trial

elif row(12:20:2) and t &gt;= 0.0 and rating.status == NOT_STARTED:
    break
    rating.tStart = t  # underestimates by a little under one frame
    rating.frameNStart = frameN  # exact frame index
    rating.setAutoDraw(True)
continueRoutine &amp;= rating.noResponse

 elif rows.event.getkeys, row(11:19:2):
     elif len(theseKeys) &gt; 0:
        break 
        key_resp_2.keys = theseKeys [-1]
        key_resp_2.rt = key_resp_2.clock.getTime()
     continueRoutine = False
 elif row(20:50:5) and t &gt;= 0.0 and rating.status == NOT_STARTED:
    break
    rating.tStart = t  # underestimates by a little under one frame
    rating.frameNStart = frameN  # exact frame index
    rating.setAutoDraw(True)
continueRoutine &amp;= rating.noResponse
       rows.event.getKeys, row[21, 22, 23, 24, 26, 27, 28, 29, 31, 32, 33, 34, 36, 37, 38 ,39, 41, 42, 43, 44, 46, 47, 48, 49]:
        elif len(theseKeys) &gt; 0:
            key_resp_2.Keys = theseKeys [-1]
            key_resp_2.rt = key_resp_2.clock.getTtime()
         continueRoutine = False
</code></pre>

<p>You should loop only once, but perform all checks inside that one loop:</p>

<pre><code>for row_index, rows in (beads_params_pinkbluegreyratingparamters.xlsx):
    if (row_index &lt; 10):
        rows.ratingscale(0:10)
    elif (row_index &gt;=10 and row_index &lt;20):
        rows.ratingscale(12:20:2)
        rows.key_resp_2(11:19:2)
    elif (row_index &gt;=20):
        rows.ratingscale(25:50:5)
        rows.key_resp_2[21, 22, 23, 24, 26, 27, 28, 29, 31, 32, 33, 34, 36, 37, 38, 39, 41, 42, 43, 44, 46, 47, 48, 49]
</code></pre>

<p>Note that there are some syntax errors in your code, e.g. <code>rows.key_resp_2(11:19:2)</code> doesn't make sense.</p>

python excel psychopy