So I have the following task:
First generate a list with strings of fictitious names for image files (e.g.my_list['image1.png','image2.png','image3.png']). Then write a while loop in which an image is randomly drawn from the list and presented until the number 1 or 2 is pressed. Instead of presenting an actual image, just use the print command (e.g. print ('image1.png') - you'll learn how to present images via PsychoPy later). First define the subject's response as a boolean (response = False). Instead of registering a response via keyboard or mouse, use the library random with its function randint to generate a random response. Finally, add an abort signal to interrupt the loop after a maximum of 20 repetitions if no response has been registered yet. Additionally, the names of the randomly drawn "images" should be cached according to their presentation and finally overwritten into a text file (.csv, or .tsv etc.) so that the order in which they were drawn is preserved.
The coding I have already done is the following, but if I try to start the operation nothing happens. There is no result.
from random import randint
from random import choice
imagefiles = ["image1.png","image2.png","image3.png"]
if 1 or 2:
response = True
else:
response = False
tries = 1
while tries <= 20:
if response == False:
print(random.choice(imagefiles))
break
tries = tries + 1