I’m making a basic stroop task test with only one routine with three components and a loop. There is a text component, a key response component and a code component to randomly determine the word displayed and the color of the word. The following code is used:
decide1 = randint(1, 3)
decide2 = randint(1, 3)
if decide1 == 1:
color = 'red'
answer = 'left'
elif decide1 == 2:
color = 'blue'
answer = 'right'
if decide2 == 1:
word = 'Red'
elif decide2 == 2:
word = 'Blue'
if color == 'red' and word == 'Red':
congruent = 1
elif color == 'blue' and word == 'Blue':
congruent = 1
else:
congruent = 0
thisExp.addData('word', word)
thisExp.addData('color', color)
thisExp.addData('congruent', congruent)
The program begins, a randomly colored word appears, and the program crashes when a response is made on the keyboard. The following error message appears:
color.addData('color_word.started', color_word.tStartRefresh)
AttributeError: 'str' object has no attribute 'addData'
This is very confusing because I never made any object named ‘str’ and I assume it is made by psychopy itself. If anyone could help me out that would be greatly appreciated.