psychopy.org | Reference | Downloads | Github

Import images in a for loop

Hello,

I am trying to import images using a for loop because I can a different image to appear in each condition.

So I used the following code:

‘’’ if Prevalence == “HR”:
if trial_resp_2.keys == ‘a’:
if trial_resp_2.rt <= 8:
#msg = ‘Correct!! You won 7 points.’
image = ‘stimuli/7tickets.jpg’
corrResps += 7
else:
msg = ‘Too slow!’
else:
msg = ‘Wrong answer!’
else:
continueRoutine = False ‘’’

and then I imported an image component as used $image instead of importing image manually from the folder. But it does not seem to work.

Do you have any idea how i can import images in a for loop?

Thank you