I am getting a syntax error in the autoJS section of an experiment I am building. The majority of the code translates perfectly fine, however it seems to have an issue with “for x,y in” code.
In my experiment I have:
for a,b in combinedList:
if a != b:
list1.append(a)
list2.append(b)
I have checked the crib sheet, but cannot see anything in there relating to this, though I might not know the terminology.
Other standard for loops (just the normal “for i in list”) work fine, it just stumbles when the comma goes in.
If anyone knows what needs to be changed to make it JS suitable that would be great.
It starts as empty but then gets populated with
combinedList = [[a1,b1],[a1,b2]] etc depending on responses. The autoJS is happy with all of that as I have to do some zipping and shuffling with the list later, but it just doesn’t seem to be able to translate the Python iteration into JS and I’m not sure how to iterate in JS.
I’ll have more time to explore this next week, but does the following solve the issue?
for Idx in range(len(combinedList)):
if combinedList[Idx][0] != combinedList[Idx][1]:
list1.append(combinedList[Idx][0])
list2.append(combinedList[Idx][1])
I can’t mark them all as solutions, but in testing they do all work. It now all translates to JS. Hopefully it’s smooth sailing with uploading to Pavlovia.