Error checking textbox text. Keeps saying incorrect no matter what

OS: Mac Big Sur version 11.2
PsychoPy version : 2021.1.4
What are you trying to achieve?: Check if textbox text is correct
tried to do the exercise from this link, including checking the correct answer.
here’s a link to my file and the conditions file:

What did you try to make it work?: tried changing the name of the correct answer column in the conditions file, tried setting the correct answer to be the same column as the number was supposed to be

What specifically went wrong when you tried that?:
keeps saying the answer is incorrect no matter what. it has not replied that any have been correct

here is the conditions file:
digitspantaskfile.xlsx (8.5 KB)

and the psychopy file:
digitspantask.psyexp (14.4 KB)

Hi Elle,

OK looks like there were 2 things going on here. First your answer variable was being interpreted as an integer, whilst your textbox.text was a string - so you needed to convert the answer to a string first before testing for equality i.e.:

if textbox.text == str(answer):
    feedback = 'correct;

Second however, it looks like the textbox was being cleared before the end routine tab. So if you adjust the code as follows:

Begin Routine:

feedback = 'incorrect'

each frame:

if textbox.text == str(answer):
    feedback = "correct"

That should do the trick - this looks like a bug and I will check it is fixed in the next release.


Thank you so much! This had me so stumped so I really appreciate the help!