Terminate loop based on number of total stimuli in list

Hi! I am looking for a way to terminate a loop after all the elements from the current selected list are all exhausted. In my experiment, I have an outer loop that randomizes 9 conditions (block1, block2 … block9) and an inner loop that randomizes the stimuli within said condition. As it stands, the participant gets presented with all the 9 conditions one after each other. I am interested in presenting the participants with only a single condition.

Let’s say a participant starts the experiment, and the first block in the random sequence is block3. After he is exposed to all stimuli within block3, I want the experiment to continue to the next section, without going to the next block that would’ve been next in line.

I implemented a code component similar to the one here Builder - terminating a loop — PsychoPy v2023.1.2, however I cannot state a set number due to block1 having more stimuli than all the other conditions. As such, I think want the code component to reference something from the audio_stimuli_loop, but I have no clue what given I am a complete newbie when it comes to Python programming. Help! Many thanks in advance!