Selecting Image Component from a Defined Dictionary

Hi there,
I’m making an experiment that involves randomly selecting images to use for the stimuli. I’ve used the code section to create a dictionary where I store the randomly selected stimuli and each key matches the names of the conditions that I have in a separate .csv file.
I want to set the image component to be something like $Dict[condition], so I’m telling it to look in the dictionary at the key that matches the relevant condition if that makes sense. But I am just getting an error message saying that the file path $Dict[condition] can’t be used.
I have noticed that if I just have the images component as $Dict[‘key1’], then it does work.
Essentially I am wondering if it is possible to set up this relative dictionary/condition combo for the image component, or if I’m wasting my time.

ps. I had seen someone set up a PsychoPy experiment using essentially the same method which is where I got the idea from.

Thanks!

Try print(Dict[condition]) to find out whether the file path is what you think it should be.