psychopy.org | Reference | Downloads | Github

Is there a way to add text that changes with each trial?

Hi, i’m very new to Psychopy coder, my experiment has 10 trials, and before each i want to add text showing which trial it is before each begins, e.g. “Trial Number X” where X is a number 1-9. Is there a way to put this into the code? or do i have to type out 9 different if statements?
I’ve attached a screenshot of my code so far, if this helps

You just need to convert whatever you’re iterating over into a string, and add it to the text of the stimulus you’re presenting. For instance, if the trial number message appears in a stimulus called “trialMessage”, and i is the variable you’re iterating, then before the stimulus is presented you just add trialMessage.text = "Trial number " + str(i) to the code. This converts i to a text string, and adds it to the text "Trial number ", and makes that the text that is displayed when trialMessage is made visible.