Create a new list based on responses and use it in another loop

Hi, I’m having problems creating a new list based on responses and use that in another loop. This is the last part of a multisession experiment. Subjects will first make yes/no memory judgments for each image (trials loop). Then I want to generate a new list based on their responses and use that list in the following pair associate learning (study loop).
Here is the builder view I have:

Here is the excel file of trials loop results:

I want to create a list for studyloop based on the responses of the trials loop. The conceptual idea is that:
If testjudg.corr == 1 and type ==“target” and CorrectSource == 1, store the correspond “Stim” “name” “type” into list A.
If testjudge.corr=1 and oldsource.corr=0 and type=target and CorrectSource=3, store the “Stim” “name” “type” into list B.
Then I need randomly choose 5 items of list A and 5 items of list B to create new pair associates. In the study loop, subjects will see one item from list A on the left and one item from list B on the right and learn the pair relationship.
I’m really having difficulty in generating this new list for study. So any suggestions or demos will be very appreciated!

The way to store is to start with


Then listA.append([vars needed separated by command])

listA[0][0] is the first value for the first row.

Thank your advice! I have made code like this
if testresp.corr == 0 and type ==“target”:
listA.append([Stim, type, Correct])
And it gives me [[‘002.jpg’, ‘target’, ‘left’], [‘003.jpg’, ‘target’, ‘left’]].
But I’m wondering how can I use this list as condition file for another loop?

Your new loop needs a loop counter (because.thisN doesn’t work online) but no spreadsheet.

nReps should be set to the desired number of trials or a large number if you intend to break the loo in code.

In the loop you can the set the image to listA[loopIdx][0] or you could have thisTrial = listA.pop() to select and remove the last item and then use thisTrial[0] for the image.