Defining correct key for stroop task while randomzing

I am building a stroop task and I am trying to define the correct key. I would use excel to do this, however, I have used code to randomize the colours, so it is not always going to be the sam. If this was in an excel file then I would have to create a long list to ensure every combination of colour and word is possible.

This is the code I have used to randomize the word and colour combinations.

This is the code I have used to create the correct key for the colour, as it is the colour that the participant should be focusing on, not the word. I am not very good at the coding part so I understand that this is probably incorrect. However, the error that I am getting is:

ioHub Server Process Completed With Code: 0
File “/Users/dm/Documents/Experimental Programmes/Stroop 2 copy/Test.py”, line 1074, in
run(
File “/Users/dm/Documents/Experimental Programmes/Stroop 2 copy/Test.py”, line 703, in run
if (keyStroop.keys == str(corr)) or (keyStroop.keys == corr):
UnboundLocalError: local variable ‘corr’ referenced before assignment
################ Experiment ended with exit code 1 [pid:98870] #################

I have moved the code component to the top, however, this did not work.

I think lines 3, 5, 7 & 9 should reference col not colours.

That is what was wrong, thank you!

1 Like