Error with code

Hi everyone, I need your help for solve this little problem. I’m trying to assign a number to some errors and these errors will be print on an excel file. In this moment, I’m working on “too late” error but on excel the right number does not appear. Too late means that the subject forgot to press a key before the end of a trial. The problem seems to be due to key_resp_2.keys== None
Here is the code:
Cattura

Wouldn’t .corr also be None, if .keys is None?

Hi, I am differentiating the situation in which a subject presses the wrong key from the situation in which a subject doesn’t press anything. For the first situation I wrote if key_resp_2.corr==0 and key_resp.corr==0 (I think that I also must add key_resp_2.keys != None) for the other situation I wrote key_resp_2.corr==0 and key_resp_2.keys== None. There are some trials in which a subject does not have to respond. I noticed that if I write key_resp_2.keys==None, as in the picture, and I make the mistake of not pressing anything the task crashes

Sorry, let me be more explicit: For the case that nothing is pressed, key_resp_2.corr as well as key_resp_2.keys will be None (I think). Therefore your second condition is never True. So what you need is simply elif key_resp_2.keys == None: ...