 Hi everyone - i’m new to Psychopy and coding so sorry in advance if this is basic!

I have managed to create a simple keyboard response task, but i’m struggling with a few bits of coding.

How do I add feedback at the end of my task, after the loop has concluded to say “Task finished!” or something similar. I also want this to appear on screen for 3 seconds.

This is the code i have right now:

for i in range(1,10): # T3: the range function starts a ‘loop’ and tells the software to run through a series of commands multiple times. Here it will run a loop 9 times, starting on number 1 and ending on number 10.
if i % 2 == 1: # if the trial is an odd number (note - % means “modulus”)
stimOn = ‘blue’
stimBlue.draw()
if i % 2 == 0: #if the trial is an even number then lines 18 and 19 will run, otherwise it will not.
stimOn = ‘red’ #draws the red circle
stimRed.draw()#draws the red stimulus (circle) onto the window so it is presented on the screen

``````win.flip() # T5: The flip command tells the software we want to present a new version of the window we previously set out
key = event.waitKeys(maxWait=5,keyList=['b','r']) # waits for either an r or b key to be pressed. If 5 seconds pass, then it moves on without a response
feedback.text = "Too long!"
if key == ['b'] and stimOn == 'blue': # if the key pressed was b and the stimulus presented was blue
feedback.text = "Correct!"
elif key == ['r'] and stimOn == 'red': # if the key pressed was r and the stimulus presented was red
feedback.text = "Correct!"
else: #T6
feedback.text = "Too long!"
if key == ['r'] and stimOn == 'blue':
feedback.text = 'Incorrect!'
elif key == ['b'] and stimOn == 'red':
feedback.text = 'Incorrect!'
feedback.draw()
win.flip()
core.wait(1.5)
win.flip()
core.wait(1)``````