# Simon experiment

Hello,
I have been trying to design a simple simon task in psychopy. I took help from an online youtube video.

Instead of using X and O, in my experiment I am trying to use red and blue square images. So, I made some changes in the code they wrote. I replaced X and O with red and blue square images. Probably I did some mistake in the syntax, that’s why there is an error showing that the for eg., blue_square.png is not defined.

Could you please check and point out the mistake and tell me the correct way to write it.
Here is the code.

``````if expInfo['counterbalance'] == '0':
bindings = {'blue_square.png': 'm', 'red_square.png': 'z'}
if thisTrial['condition'] == 'incongruent':
if thisTrial['stim'] == 'blue_square.png':
thisTrial['stim'] = thisTrial['stim']
'red_square.png' = ''
ans = 'm'
elif thisTrial['stim'] == 'red_square.png':
'blue_square.png'= ''
'red_square.png' = thisTrial['stim']
ans = 'z'
elif thisTrial['condition'] == 'congruent':
if thisTrial['stim'] == 'blue_square.png':
'blue_square.png'= ''
'red_square.png'= thisTrial['stim']
ans = 'm'
elif thisTrial['stim'] == 'red_square.png':
'blue_square.png'= thisTrial['stim']
'red_square.png' = ''
ans = 'z'
elif expInfo['counterbalance'] == '1':
bindings = {'red_square.png': 'm', 'blue_square.png': 'z'}
if thisTrial['condition'] == 'incongruent':
if thisTrial['stim'] == 'blue_square.png':
'blue_square.png' = ''
'red_square.png' = thisTrial['stim']
ans = 'z'
elif thisTrial['stim'] == 'red_square.png':
'blue_square.png' = thisTrial['stim']
'red_square.png' = ''
ans = 'm'
elif thisTrial['condition'] == 'congruent':
if thisTrial['stim'] == 'blue_square.png':
'blue_square.png' = thisTrial['stim']
'red_square.png' = ''
ans = 'z'
elif thisTrial['stim'] == 'red_square.png':
'blue_square.png' = ''
'red_square.png' = thisTrial['stim']
ans = 'm'
``````

I hope you can help me.
Thank you

This doesn’t make sense to me since neither is a variable.

I’m going to guess that you have a stimulus component called `red_square` and that you are trying to update its image attribute. The way to do that is to use the correct attribute name, which is `.image`, and not to put that in quotes. e.g.

``````red_square.image = thisTrial['stim']
``````

The docs for that attribute are below. You need to refer to the documentation rather than just guess at attribute names: