#### Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Supported by

# Shuffling a list in a loop once, then running it multiple times

edited January 3

Hello,

I have a loop that runs several times that should random a variable value (all values are letters, in my case). I have 18 values, and the loop runs 7 times in each sequence. Also, I don't want the same value to appear more than once. I thought I should use the "shuffle" command in the loop item and pick "sequential" under "Order", but while it does seem to shuffle the list, I guess the loop runs itself and reshuffles the list in each loop-run so I end up getting a certain letter (variable value) more than once in each sequence, occasionally.

Any idea what am I getting wrong?

Thank you,
Omer

• Hi Omer,

Hmm, it's not entirely clear to me what you want to do.

• The title of your discussion suggests that you want to determine the order of a loop once, and then run the loop in that same order multiple times. Do I understand that correctly?
• What kind of constraints do you want to apply to the order? Right now, target_letter has 18 unique values, so I don't see how repetitions within a loop can occur, nor how you can avoid repetitions if you run the loop 7 times.

Cheers!
Sebastiaan

There's much bigger issues in the world, I know. But I first have to take care of the world I know.
cogsci.nl/smathot

• Hey Sebastiaan,

First, thank you for you answer. I havn't managed to get to this project lately but I'm getting back to it now (that's why it took me so long to respond back. apologies).

So I guess I wasn't clear enough as of what is it that I'm trying to achieve. Maybe I'll open by briefly describing how 1 trial in my experiment should look like -
1. A letter (from a bank of 18 unique letters in total) should appear.
2. 4 consecutive (timed) tasks appear.
3. This sequence of events should appear for 6 more times or 7 in total, so - 7 letters and 28 tasks in total.
4. Subjects will report the list of letters into a text input form.

That's the basic structure of a trial in my experiement.
Now, for what I can't figure out - I want the order of letters to be random and with no repeats within each trial. From your 2nd note I understand that my understanding wasn't correct - the way it's built right now (same as in the picture above) I was basicly creating a different list each time and calling the 'target_letter' gave me the first value of the list each time, that's why I'm getting repetitions.

While trying to fix this issue now, I tried to call 'target_letter' more than once within a loop to see if that would do the trick but that resulted in getting the same value for 'target_letter' for the whole loop. Plus, it felt like the design was quite 'stupid' so I'm not sure that's the way I should be heading with this.