| Reference | Downloads | Github

Saving typed participant responses as a list

I am creating a recall task where participants see 7 words sequentially and have to recall them by typing each word.
I’m new to this, and I can’t figure out how to save participants’ typed 7 word responses as a list that I can use to compare to the ‘correct list’ (to assess for accuracy).
Any suggestions are appreciated.

This should do it- just replace the space with whatever participants use to separate their words:

Store participants’ words in an object, such as “s”
s = ‘I remember words really well’
d=s.split(" ")
[‘I’, ‘remember’, ‘words’, ‘really’, ‘well’]

In this case, the words were separated by a space and stored into a list.

Thank you! I am getting an error message that I am not sure if it is coming from my previous code which allows participants to enter their typed words, or from your recommended code.
Any guidance would be greatly appreciated.
The text object that allows participants to see their typed responses is called ‘text’.

text.text = ‘’ "
keys = event.getKeys()
if len(keys):
if ‘space’ in keys:
text.text = text.text + ’ ’
elif ‘backspace’ in keys:
text.text = text.text[:-1]
elif ‘lshift’ in keys or ‘rshift’ in keys:
modify = True
elif ‘return’ in keys:
text.text = ‘’.join(key.keys)
continueRoutine = False
if modify:
text.text = text.text + keys[0].upper()
modify = False
text.text = text.text + keys[0]
s = text.text

thisExp.addData(“typedWord”, text.text)

Error message:

SyntaxError: invalid syntax
Alert 4205:Python Syntax Error in ‘Each Frame’ tab. See 'Then:
’ on line number 21 of the ‘Each Frame’ tab.
For further info see

Experiment ended.

When @arkadiy typed “Then:”, that was an English instruction meant for you, rather than Python code. As the error message indicates, you should delete that line, which doesn’t mean anything to the Python interpreter.

Also the d by itself is meant to show what the output would be in a Python interpreter. It might not do anything in a Python script (if you need to see the result explicitly, use print(d) instead.)

Makes sense. Thank you so much!!

I am getting an error that d is not defined, which I believe I have to do in the ‘begin experiment’ tab of the builder code, correct? (I didn’t get an error about s, but I assume I have to define this as well). How should I be defining these objects if they are to serve as lists?