Random color in emotional Stroop test

Hi there,

I’m programing an emotional Stroop test with 300 words and want them so show up in a random order and random color. The random order I got working but not in a random color. The colors are yellow, green, blue and red. I’m working with the builder and I’m really frustrated. I appreciate your help. Thanks in advance

1 Like

Hi @Kate_Boe, you could set the color of your word to $col, set to “set every repeat”, and then use the following code in a code component of your trial:

Begin experiment

import random

colors = ["yellow", "green", "blue", "red"] * 75
random.shuffle(colors)

Begin Routine

col = colors.pop()

Also make sure that you add something like this so that the selected colour gets saved in the data on each trial. This can’t happen automatically for variables created in code (as opposed to those read in from conditions files):

thisExp.addData('word_colour', col)
1 Like