I am currently designing an experiment where the user has to press either “left” or “right” on a screen sequence which would be used in a later screen input.
Window 1:
Do you think that A or B will happen?
A: press left arrow key
B: press right arrow key
Window 2 has a code behind it something of the sort from below in order for variables to be output in the backend for future analysis.
if(‘left’ in keyDecisionResponse.keys):
something to happen
elif(‘right’ in keyDecisionResponse.keys):
something else to happen
However, if the user doesn’t press anything (which could happen if the user is not paying attention), I receive the error: TypeError: argument of type ‘NoneType’ is not iterable
Experiment ended. Therefore, I would like to automatically assign ‘left’ to ‘None’ in Window 1, something of the sort:
if (‘None’ in keyDecisionResponse.keys):
keyDecisionResponse.keys = ‘left’
It does not work. Also, I tried several things, but none of them worked.
Can you please help? Thanks.
Check if keyDecisionResponse.keys
is type NoneType
then select default.
if keyDecisionResponse.keys is None:
keyDecisionResponse.keys = "left" # Or however you assign it
Also, make sure that you retain indentation and use proper quotation marks.