OK, then comparing practice_type
to your corrAns
variable will never evaluate to True
, as they are quite different things. practice_type
is a complicated object (a TextBox2
stimulus) that has lots of attributes (like a position, font style and colour, whether it is currently visible, and so on). The text it contains is just one of those attributes. An analogy would be that you can’t directly compare the identity of a person to a car, just because that car happens to contain a driver. You need to directly compare like-with-like, in this case:
if practice_type.text == corrAns: # refer directly to the text attribute
This code should only run at the end of the routine, not on every frame. That way the comparison is only made when the response is complete, not while it is still being typed (and possibly getting edited).
That wasn’t designed to change what happened in the data but to give you debugging information in real-time: it should have revealed that you were comparing incompatible object types (a TextBox2 stimulus begin compared to a string of characters).
That is because you have an if:
line with nothing following it. Also, as above, a TextBox stimulus won’t have a .lower()
method, only strings do, so you need to apply it there:
if practice_type.text.lower() == corrAns.lower():
# having something here is important
EDIT: PS there does seem to be a bug at the moment about the content of the text box not being stored correctly at the end of a routine, so for the timbering at least, you might indeed need to do the comparison on each frame, and just trust that the last one will supersede any previous ones: