Randomizing Two Lists of Stimuli within a Single Loop - Online

I am new to PsychoPy, and am trying to replicate the example from this tutorial on randomizing two lists of stimuli within a single loop: https://www.youtube.com/watch?v=toQ2enxAv1E

I have been able to replicate this and run it locally, but when I push the experiment to Pavlovia I keep getting the following error:

I feel like I am missing something here, but I am not sure what I did incorrectly. Any advice on how to randomize two columns in the same loop in a way that also works online?

Thank you so much in advance!

After getting your experiment up and running locally (in python), you need to convert the python code to Javascript so that it runs online. PsychoPy has this amazing auto ‘translator’ turn python to JS for you. But it is not perfect, you probably will need to go through a debugging process. You can open your browser console to read what your program complains about.

For example, your num_item variable is not defined. JS has different scope for variables (compared to python), the variables defined within a function won’t be readable globally. That may be the reason why your local python program works but JS doesn’t.

You may find this link helpful PsychoPy Python to Javascript crib sheet

Try putting num_items=0 in a Begin Experiment tab if a code component.

Thank you so much for the tip! I tried this, but it no longer ran locally. It did not give me an error, though. It just closed, as if the experiment had ended.

This is what the Builder looks like:

This is the “codeinit” code component:


Here is the second routine, and the associated code component and loop info:




Is anything jumping out at you?