If this template helps then use it. If not then just delete and start from scratch.
OS Win7: PsychoPy version 1.90.1:
**Standard Standalone? yes: What are you trying to achieve?:
Produce an outcome that results in ‘20’ in 5% of trials, and ‘0’ in 95% of trials as a text stimulus.
What did you try to make it work?:
I tried to make as it’s suggested here in “Indivisibility” chapter.
The error is not in the highlighted code, which does what is expected (although you could drop the \ line continuation character perhaps).
The error is pointing to a TextStim object, which does not exist in the code you provided. You should list the entire text of the error message.
You don’t need to import random as Builder imports various random functions from the numpy.random library. In particular, it imports numpy's shuffle() function directly, so you can just type shuffle(points), rather than random.shuffle(points), and then you’ll be consistent with Builder in using numpy rather than the Python standard library’s randomisation functions.
I have many loops that represent different lotteries - it’s a dumb way I could come up with to get randomisation right. I get error from the loop “lot2” in “code_9” (I set the random seed so I start from this loop).
The code that includes TextStim of the stimulus from the coder view: