Code error while counterbalancing experiment versions

OS: Win10
PsychoPy version : PsychoPy 2020.2.10
**Standard Standalone? ** : y
What are you trying to achieve?:
I’m trying to counterbalance experiment versions for 3 groups.

So, for each group, I want they are assigned with different trials. Specifically, one for just text instruction only, another for 2 study trials, and the other for 6 study trials.

What did you try to make it work?:
I inserted 3 different set of trials with loop and for nReps$ of each loop, I put ‘nRepsA’, ‘nRepsB’, and ‘nRepsC’.
Then, at the [Begin Experiment] of code, I put this code below.

What specifically went wrong when you tried that?:
It seems there’s an error in ‘if~ else’ code, but I can’t figure out what is the problem.

Thank you for your time,

Hello,

Math.floor/random is JS code which Python does not recognize. You should just use random().

Thanks for the comment,
but actually there was no error message when I put only the first line of code( math.floor part).

As soon as I type ‘if’, the error message came out on the right side of the code panel of ‘Begin experiment’.

What you have is not formatted according to Python conventions, which is why you have the error.

Try writing

randNum=[1,0,0]
shuffle(randNum)
nRepsA=randNum[0]
nRepsB=randNum[1]
nRepsC=randNum[2]
1 Like

Thank you so much ! It worked…!

May I put one more question?

Does this ‘shuffle’ function randomly(same probability) assign every element in the square bracket?
Cause what I’m trying to get is to have equal random assignment of one of the three different tests to every participants.

I see. I should have used different code format that matches python logic.
Thank you for the reply…!

If you want to have equalish assignment across participants then you probably either need to randomly assign in Qualtrics or use my web app

https://moryscarter.com/vespr/pavlovia.php