I need some help rewriting some Python code, to exclude the zip and cycle functions I currently have in it if possible. I am still a coding novice, so I'm not sure if it's doable.
I am using a program called PsychoPy to build experiments for students, wherein we can also upload them online. For online upload there is an autoJS option, however there doesn't appear to be a JS equivalent I can find for zip and cycle.
My code is as such
for x in savedImages1:
for y in savedImages2:
if x == y:
choiceImages.append(x)
for z in choiceImages:
while choiceImages.count(z) < 60:
choiceImages.append(z)
combinedList = list(zip(choiceImages, cycle(labelsWhole)))
combinedList = [list (elem) for elem in combinedList]
random.shuffle(combinedList)
Essentially what is happening here is there is a list (choiceImages) where images they have chosen previously populate this list (60 times). So if you picked image A, it would add image A to choiceImages 60 times. labelsWhole is a premade list, also consisting of 60 items, where their image choices are paired against each image in labelsWhole (e.g [A,A],[A,B],[A.,C] etc). This list is then shuffled up so the image pairs remain (e.g [A,B][B,E] etc). I zipped them as a list so the image pairs remain unaltered during the shuffling, as if I just shuffled choiceImages and labelsWhole separately I could end up with [A,B],[A,B] [B,A] [B,A] where I should only get [A,A] [A,B] [B,A] [B,B]. Hopefully this makes sense. I then later split the pairs into two separate lists, which then remain unaltered.
So I need a way to, without zip or cycle functions:
Pair the images with each other, so that each image is only paired against another once, so it can be shuffled and split plater.
Cycle through labelsWhole to add additional iterations (for example, if they selected 4 images to begin with, choiceImages would have each image * 60, so labelsWhole would need to be added to a list 4 times).
I hope I've explained this well enough. If not please let me know where it doesn't make sense, and I will try to explain it better.
Best wishes