Store correct with mouse click

I have created an experiment where users are required to click certain objects using the mouse. I created a grid of clickable stimuli and added them to the mouse component. In my conditions sheet, I made sure the corr_ans was the same as the correct clickable stimuli. I then used this code as recommended in another thread:

if stim_mouse.clicked_name == corr_ans:
    correct = 1
    correct = 0
trials1.addData('correct', correct)

The code is in the End Routine tab.
I have found that no matter what is pressed, be that correct or incorrect, the “correct” column never shows anything other than a 0.

Hi @Jdigg,

to find out where the error is, you can insert


right before the code, which you posted. This will print both values to the console in the Runner. This way you can see why PsychoPy apparently does not consider these two values as being equal and make the necessary adjustments.

Hope that helps!

So it turned out that it was saving it as a list. For example the code you provided would print:


So I changed my code to if stim_mouse.clicked_name[0] instead and that fixed the issue.