psychopy.org | Reference | Downloads | Github

Simple Question

Hi,

I want to create a message in a feedback display based on if the participant either:

  1. Pressed the right key
  2. Pressed no key
    3. Pressed no key when it was correct to press no key
  3. Pressed the wrong key

if not KeyPhase1.keys :
if CorrectKey=‘space’
.,.,.,msg=“Too slow!”
…else:
.,.,.,msg=“Correct!”
elif KeyPhase1.corr:#stored on last run routine
…msg=“Correct! RT=%.3f” %(KeyPhase1.rt)
else:
…msg=“Wrong!”

I get an error for the cursive line - what is it that I did wrong? #codingnoob
“CorrectKey” is stored in my excel sheet.

The output of if CorrectKey='space' should be true or false because you’re evaluating an if statement, but using a single equal sign is an attempt to set the value of CorrectKey to be ‘space’, which I take is the probable source of the error. You need to use a double equal sign to check that CorrectKey is 'space'.

Let me know if this doesn’t fix your issue. Also, next time you post on this forum, be sure to post the exact error message that you get from the shell output.