Hello!
I am building a online self-paced reading task with moving window paradigm. Thanks to other people, I was able to find this code to develop what I want for my experiment.
However, when I tried to type these codes in my code component and translate them to JS code, I get this kind of errors repeatedly: /* Syntax Error: Fix Python code */
Upon completing word ‘for’, I get this error. Could anyone help me out of this issue?
wordNumber = -1 # -1 as we haven’t started yet
now define a function which we can use here and later on to replace letters with ‘-’:
def replaceWithdash(textList, currentWordNumber):
dashSentence = ''
for index, word in enumerate(textList): # cycle through the words and their index numbers
if index != currentWordNumber:
dashSentence = dashSentence + '-' * 6 + ' ' # add a string of dash characters
else:
dashSentence = dashSentence + word # except for the current word
return dashSentence # yields the manipulated sentence
now at the very beginning of the trial, we need to run this function for the
first time. As the current word number is -1, it should make all words ‘-’.
Use the actual name of your Builder text component here:
text.text = replaceWithdash(sentenceList, wordNumber)