Displaying one of several error messages after a trial, several of the messages have fixed text, but one must depend on the recorded response

If this template helps then use it. If not then just delete and start from scratch.

OS (e.g. Win10): macOS Big Sur
PsychoPy version (e.g. 1.84.x):
Standard Standalone? (y/n) If not then what?:
I wish to display one of several error messages, ending on what just happened in my task. Roll error messages have fixed text, but, some of them need to vary. These are indicated in the control file with x X.

We would like the error message to depend upon the key that has just been pressed, such that a response of correct is displayed when the response is correct, and an error when the responses I’m not correct. Trial feedback should be generated using this code component.

if not practice_resp.keys :
    msg="Failed to respond"
elif resp:#stored on last run routine
    msg="Correct!"
else:
    msg="Oops! That was wrong"

Can anybody advise how to get the output of this code to replace the message X, in the error message column of the control file? If The code is unclear, the correct responses are stored in the Resp column of the spreadsheet.

simon.csv (181 Bytes)

Thank you so much!