psychopy.org | Reference | Downloads | Github

TypeError message, must be real number not list

Hi. I’m trying to run my ‘go no go’ task and I run into a problem when I do not press a key (the ‘no go’ condition) this message comes up. Please help!

Hi @NMah, if you check for a correct response before you attempt to format the msg for correct answers, you should avoid this error. E.g.,

if resp.corr:
    msg = "Correct! RT=%.3f" % (resp.rt)
else:
    msg = "Incorrect"

Hi
Thank you for your reply! This is my code, I have checked to see if it’s correct and somehow it’s fine in all conditions (when I press the space bar for the ‘go’ conditions) only when I don’t press it for one of the stimulus that comes up, that’s when it crashes.

Ah, then I guess no response is also a correct response? Is it the same error? If so, try:

if resp.corr and isinstance(resp.rt, float):
    msg = "Correct! RT=%.3f" % (resp.rt)
elif resp.corr:  # because no response is correct, but no RT is recorded 
    msg = "Correct!" # or just pass if no feedback here e.g., pass
else:
    msg = "Incorrect"
1 Like