I am getting a reference error, which I believe is from the " zip () " function not being available in JS. Does anyone know the equivalent code? I believe I may also run into an error shortly after as I have used the “cycle” and “shuffle” functions as well. They are all in one chunk of code which I have added below.
combinedList = list(zip(choiceImages, cycle(labelsWhole)))
combinedList = [list (elem) for elem in combinedList]
random.shuffle(combinedList)
I have the code now set to “both” as I have had to remove the import settings for random and cycle.
I’m still quite new to coding so I’m not sure what I’d be able to replace zip and cycle with.
The code pairs the choice images against set images (which is where the zip and cycle are coming in) so that this list can be shuffled and then separated to ensure the right pairings later.
combinedList = []
for Idx in range(len(choiceImages)):
combinedList.append([choiceImages[Idx],labelsWhole[Idx%len(labelsWhole)]])
shuffle(combinedList)
This should work locally and online (via the Auto translate). I’m not sure what combinedList = [list (elem) for elem in combinedList] is supposed to do, so I’ve left that bit out.
This solved a question I’ve been working to solve! But, is there a way to then split the combined list into two (a la List1, List2 = zip(*CombinedList))?