Coding for a No-Go Task

Hello everyone!

I am creating a dual-task experiment with a no-go task and as I am pretty new to Python I do face some issues.

I will let you know what the instructions of the experiment are in the following:

For Task 1 (LEFT HAND) :
If the number is smaller than 5, respond using your middle finger (key ‘A’)
If the number is larger than 5, respond using your index finger (key ‘S’)

For Task 2 (RIGHT HAND) :
If the number is 5, respond using your index finger (key ‘K’)
If the number is other than 5, DO NOT respond.

In the keybord for task 2 I put ‘None’ as an allowed key, as well as in my correct answers within the excel sheet.

For the feedback, I used the following code:

if t1_resp.keys != t1_correct and t2_resp.keys == t2_correct:
msg = “wrong response to the first task”
elif t2_resp.keys != t2_correct and t1_resp.keys == t1_correct:
msg = “wrong response to the second task”
else:
msg = “correct”

The experiment runs but the feedback is given the wrong way. I was applying different suggestions I found in this forum here, but none of it worked. Maybe there is an easier way to create the feedback code?

Thanks for your help!

Various_Feedback.psyexp (29.9 KB)

Is it that you’re missing a “both wrong” condition? You’re saying if only the first is wrong, do x, if only the second is wrong, do y, otherwise (meaning either both correct or both wrong), assume correct. You might need to add:

if t1_resp.keys != t1_correct and t2_resp.keys == t2_correct:
    msg = “wrong response to the first task”
elif t2_resp.keys != t2_correct and t1_resp.keys == t1_correct:
    msg = “wrong response to the second task”
elif t2_resp.keys != t2_correct and t1_resp.keys != t1_correct:
    msg = "wrong response to both tasks"
else:
    msg = “correct”

Thanks a lot for the hint. You were right, I missed this condition. However, it did not solve my problem with the No-Go-Feedback. Whenever the trial of task 2 is a no-go, it still tells me “wrong response to the second task” (because no key is hit). So my mistake should lie somewhere there…

Why do you feel that you need two separate keyboard components?