Using text to code Moving Window paradigm

Hello,
I am coding an Moving Window paradigm. In this experiment, I need to press “space” everytime to print a word of a list. Here are my problems:
1.It should show me the first word “I” when I first press “space”, but I get a [ ]
2.At the end of the experiment, the outcome shoul be “I am a Hero !”, but it shows me [‘I’,‘am’,‘a’,‘Hero’]. I don’t need [’’,’’,’’,’’] and the last word missed.
Here is my code:

from psychopy import core, visual, event
win = visual.Window(color = 'white')
Text1 = ['I','am','a','Hero','!']
for i in range(5):
    key = event.waitKeys(keyList = ['space','escape'])
    if key == ['space']:
        Text_1 = visual.TextBox2(win, text = Text1[0:i],color = 'black', font = 'Open Sans' )
        Text_1.draw()
        win.flip()
    elif key == ['escape']:
        win.close()
        core.quit()

Thank you in advance for any aid you can give me!
Shanqing

you should wirte :core.wait(2)

If you supply a list to a text stim, it will convert it to a string, which is what you’re seeing. Instead of supplying the raw list, do this:

" ".join(Text1[0:i])
1 Like

Thank you so much! It reall helps me.