Correct Answer Registered as Incorrect

Hi all,

I’m having issues getting my experiment to record the correct answer. It seems to be registering as incorrect no matter what.
I’m new to Psychopy so perhaps this has a simple fix?

OS: Windows 10
PsychoPy version: v2021.2.3
Standard Standalone? (y/n): y
What are you trying to achieve?: trying to get store correct answer

What did you try to make it work?:
I set “Correct answer” field to match the column of the correct answer in conditions.xlsx (CorrectAns)

What specifically went wrong when you tried that?:
However, the .corr column registers as 0.

Here’s the part of the python code that should correspond to logging the correct response, but I can’t seem to find anything wrong with it:


if CorrectAns in key_resp.keys:

Or simply put $CorrectAns in the Answer field of the keyboard component.

Thanks for the response.

I tried:

and it gave me a TypeError
TypeError: 'in ’ requires string as left operand, not float

So I tried:
But it just ended up giving incorrect again even though I was pressing the correct key (‘4’ for the first 2 trials).

For your second suggestion

Or simply put $CorrectAns in the Answer field of the keyboard component.

Was this not the correct way to do it (pic below)? This is the key_resp properties.

Does it work when the correct answer is a letter?

You could try putting the correct answer in quotes in the spreadsheet.

Yes, when I changed CorrectAns to letters instead of numbers, the correct answer is now registering correctly. Thanks!