Participants input is correct but categorized as false

OS (e.g. Win10): Win11
PsychoPy version (e.g. 1.84.x): 2024.2.4
Standard Standalone? (y/n) yes
What are you trying to achieve?: Participants replicate a letter sequence into a textbox and get feedback whether the input was correct or false. Wrong input always gets categorized correctly as false, but I noticed in trial that correct input often gets categorized as false. This seems to be completely random.

See here for more information on the experiment Showing next sequence after a correct answer
This is the code I´m using:

wdh_falsch_counter = 0

if inputText.text == sequence:
    thisFeedback = 'Richtig!'
    wdh_falsch.finished = True
else:
    thisFeedback = 'Falsch!'
    wdh_falsch_counter += 1
    if wdh_falsch_counter == 2:
        wdh_falsch.finished = True
        wdh_falsch_counter = 0

thisExp.addData(‘corrsequence’, thisFeedback)

What did you try to make it work?:
Since I have no idea what the problem might be, I only tried to add code to ignore upper/lowercase letters but that didn´t do anything. But the code might have been wrong, I changed this line if inputText.text == sequence: to if inputText.text, lower == sequence.lower:
I also don´t think this is the cause of the problem, since my original sequences are written in uppercase and I do the input the same way.

Hello @LAUS

well, in the post Showing next sequence after a correct answer, the code is

if input.text == sequence:

not

if inputText.text == sequence:

You could add a print( sequence) command and `print(input.text) before the if-construction to check the vaslue of these two variables.

Best wishes Jens

Hello Jens,

thanks for your answer! I tried changing the code to:

wdh_falsch_counter = 0

print( sequence)
print(input.text)

if input.text == sequence:
    thisFeedback = 'Richtig!'
    wdh_falsch.finished = True
else:
    thisFeedback = 'Falsch!'
    wdh_falsch_counter += 1
    if wdh_falsch_counter == 2:
        wdh_falsch.finished = True
        wdh_falsch_counter = 0

thisExp.addData('corrsequence', thisFeedback)

but this error message occurs:
print(input.text) AttributeError: 'builtin_function_or_method' object has no attribute 'text'

Hello @LAUS

Well, I do not know what your components are called. What happens if you change it back to
inputText.text?

Best wishes Jens

Hi Jens,
thanks again for your quick answer.
The sequences and the input are being printed but the problem remains.

If they look the same, try if sequence in inputText.text: which will ignore additional spaces, etc.

Hello

I am sorry, but if input.text throws an error, how can print(input.text) work? What do you get when you insert the following print command': print(input.text == sequence)`. It should print True if both strings match and False if they do not.

input.text is a textbox-component?

Take the following toy-experiment.
loopTemplate1.xlsx (17.9 KB)
Textbox.psyexp (15.5 KB)

It has two trials. Type Test in the first trial and Lampe in the second trial. End a trial with a mouse click. Check the console for the output.

Best wishes Jens