Key_resp.keys initializing with '[]' as the first element

OS (e.g. Win10): win 10
PsychoPy version (e.g. 1.84.x): 2022.2.5
Standard Standalone? (y/n) y
What are you trying to achieve?:
initialization of a variable for calculating a correct response within a staircase loop.

What did you try to make it work?:
Ive tried a number of things. One thing ive tried was to eliminate the first element with the following code:
#fix for first element equaling ‘
if key_resp_2.keys and key_resp_2.keys[0] == :
key_resp_2.keys.pop(0)

What specifically went wrong when you tried that?:
Nothing seems to have an effect. I have a staircase loop prior to this with very similar code, but the problem persists with the second staircase loop. All variables are unique to their respective loops.

There is no error.
|response_correct_color| key_resp_2.keys| correct_answer_color| StairLoopColor.response|

|None| L 1
0 L a 1
1 a a 1

Hi,

What you see there is square brackets ([ and ] ) and in Python they denote a list. It’s not a value. Therefore the snippet if key_resp_2.keys and key_resp_2.keys[0] == []: key_resp_2.keys.pop(0) does nothing as this is an empty list and certainly it does not have the value of .

If you explain exactly what you need to do perhaps we can help.

Thanks

Best wishes
Yiannis