psychopy.org | Reference | Downloads | Github

Please help me to find what is wrong with my coding!

Dear Psychopy Community:

How can I write a code in the feedback to execute this command?
When you see the image of the “glass”, press the “a” key, and whenever you hear the sound of the “glass”, press the “l” key.
If the participant answers correctly, play a green emoji for the images and a pleasant sound for the sounds. And if he does not recognize or lose the image or sound of the “glass”, a red emoji or an unpleasant sound will play.
Also, the participant should not respond to any other image such as radio and any other sound and should not receive any feedback.
I wrote this code but it does not work properly.

These are my codes

if CorrectAns:
   msg = 'D:\PHD PROJECT\Selected Material for Intervention\CorrectFeedback.jpg'
   correctNumber = correctNumber + 1
else:
   msg = 'D:\PHD PROJECT\Selected Material for Intervention\IncorrectFeedback.jpg'
if CorrectAns:
   msg = 'D:\PHD PROJECT\Selected Material for Intervention\Pleasantsound.ogg'
   correctNumber = correctNumber + 1
else:
   msg = 'D:\PHD PROJECT\Selected Material for Intervention\Unpleasantsound.ogg'

Thank you in advance for your great help!

This code is functionally the same as:

if CorrectAns:
   msg = 'D:\PHD PROJECT\Selected Material for Intervention\CorrectFeedback.jpg'
   msg = 'D:\PHD PROJECT\Selected Material for Intervention\Pleasantsound.ogg'
   correctNumber = correctNumber + 2
else:
   msg = 'D:\PHD PROJECT\Selected Material for Intervention\IncorrectFeedback.jpg'
   msg = 'D:\PHD PROJECT\Selected Material for Intervention\Unpleasantsound.ogg'

Do you have different keyboard components monitoring for ‘a’ and ‘i’ or one where CorrectAns is either ‘a’ or ‘i’?

In what way(s) does it not work properly?