OS (e.g. Win10): Win 10
PsychoPy version (e.g. 1.84.x): v2020.2.10
What are you trying to achieve?:
HI ALL!
I want randomly select 10 pictures from a folder as stimulus, then I wrote the flowing codes with Code Component in the begin routine tab, but showing only one picture that the loop will finish.
How should I modify the codes, and all 10 pictures will appear on the screen.Thanks
What did you try to make it work?:
import os
import random
filenames= os.listdir('./pics/')
random.shuffle(filenames)
list_for_centers=filenames[:10]
for item in list_for_centers:
target='./pics/'+item
print(target)
What specifically went wrong when you tried that?:
Showing only one picture that the loop will finish.