How to stop conditions from being repeated in a nested loop

I created a complex span task in builder that has a fair amount of code added to it. The problem I am having is with a specific routine that is within a nested loop. This routine shows a randomly selected sentence from a conditions file. The problem I am having is that sometimes, a sentence is repeated, and I want each sentence to be shown only once. I have a screenshot of the sequence in question below. The conditions file is linked to the innermost loop, which is set to random with one repetition. The middle loop is to present a variable number of alternations of sentences and individual letters. Its iterator is set with a variable, and the loop type is random. The outer loop sets the number of trials that include all of the other routines shown (that do not repeat within a sequence). It is set to run a fixed number of times, and the loop type is random. Also, I would like to avoid doing anything I would need to reverse engineer so this would run online. (I’ve already done a fair amount of that, thanks to Wakefield Morys-Carter’s extremely helpful crib sheet.) This is literally the last problem I’m having with this program, so any help would be greatly appreciated (it’s for my grad student’s thesis project). Thank you.

This thread may have some helpful suggestions: Randomisation between and within loops without repetition

Thank you - I’ll try this. Two of the challenges I’m facing is that the middle loop runs a variable number of times throughout the task based on a variable called set_size whose value is set by a list of integers that gets shuffled at the start of the program. The other challenge is that the sentences that are presented either make sense or they don’t, and each has a value of the other variable in the conditions file (makesSense) that is used to determine whether the response to the sentence (i.e., whether it makes sense) is correct. If I had a way to add a variable to the conditions file (e.g., wasSelected) to use as a flag, each time a row was selected, have the flag set to True, and use an if statement to check if a row was selected, and if it was, select another row, I think the problem would be solved (which would be trivial for me to implement if I was using C or C++ instead of python). I think your solution might work if I import the master list at the start of the experiment and shuffle it, then create a single new list from the complete list at the start of the routine of length set_size, as long as it adds both variables in the row.