Feedback is off by 1 trial

The feedback I have for my trials, are feedback from the previous trial instead of the current trial. I have no idea why and have tried many alternatives to get the correct trial feedback.

begin experiment window:
numbersShownp =
trialCountp = 0
thisFeedback = ‘’

begin routine window:
print(“trialList test sessionp”)
print(trialListp)

thisTrialTypep = trialListp[trialCountp]
thisNumberp = “0”
allNumbersp = [“1”, “2”, “3”, “4”, “5”, “6”, “7”, “8”, “9”]
numberSetp = allNumbersp

if thisTrialTypep == 0: # not an n-back trial
if len(numbersShownp)>np: # do not select the number n-back
print(numberSetp)
print(numbersShownp[-np])
numberSetp.remove(numbersShownp[-np])
shuffle(numberSetp)
thisNumberp = numberSetp[-1]
corr_ans = ‘right’
elif thisTrialTypep ==1: # an n-back trial
thisNumberp = numbersShownp[-np]
corr_ans = ‘left’

#my feedback is 2 back; so i need to make it the same as the current trial
#i may need to add a counter or get the correct feedback for 2 forward
#or start feedback at 2 after

if trialCountp > 2:
if not key_resp.keys:
thisFeedback = “Please Respond”
elif key_resp.corr == 0:
thisFeedback = “Incorrect”
elif key_resp.corr == 1:
thisFeedback = “Correct”

numbersShownp.append(thisNumberp)
trials_trainp.addData(‘trialCountp’, trialCountp)
trials_trainp.addData(‘itemPresentedp’, thisNumberp)
trials_trainp.addData(‘trialTypep’, thisTrialTypep)
trials_trainp.addData(‘corr_ansp’, corr_ans)
trials_trainp.addData(‘feedback’, thisFeedback)

end routine window:
trialCountp +=1

Is your code component below your feedback text component?

The feedback text component is after all the main code