If this template helps then use it. If not then just delete and start from scratch.
OS (e.g. Win10): 10
PsychoPy version (e.g. 1.84.x): 2021.2.3.
I am building a online self-paced reading task with moving window paradigm.Following the code snippets others have posted, I am developing an experiment. However, when I try to run the experiment, I get this following error message and I cannot move forward.
sentenceList = sentence.split()
NameError: name ‘sentence’ is not defined
I realized that this error is quite common in psychopy and people might come across this type of error at some point.
However, I checked several times to make sure that I’ve inserted the correct variable name ($stimulus) in my text component and my excel sheet has the same colum name.
I am stuck at this problem…Is there anyone who can enlighten me?
This is my code component:
wordNumber = -1 # -1 as we haven’t started yet
def replaceWithdash(textList, currentWordNumber):
dashSentence = '' for index, word in enumerate(textList): # cycle through the words and their index numbers if index != currentWordNumber: dashSentence = dashSentence + '-' * len(word)+ ' ' # add a string of dash characters else: dashSentence = dashSentence + word # except for the current word return dashSentence # yields the manipulated sentence
MyText.text = replaceWithdash(sentenceList, wordNumber)