Add and substract values as feedback

Description of the problem:
The study im running it’s like a token game. At the start you have 20 tokens on score and on every frame it presents a textbox to insert a number from 0 to 20 (response), this value is supposed tosubstract it from the initial mount of tokens and then add bonus tokens (b) at the end of the repetition which are also randomized from an excel and it must be printed at the end. It is supposed to have 5 reps and the final number of tokens are shown at the end of the loop and it’s supposed to change the value at the start.

I’ve been trying with this on the code (Each Frame)

token == score - response + bonus

And at the end of the routine


the messsage it shows me its

File “C:\Users\valen\Documents\Universidad\5to año\9no semestre\Tesis\”, line 615, in
token == score - response + bonus
NameError: name ‘token’ is not defined

sum_textbox_09_21.psyexp (33.4 KB)
value.xlsx (13.8 KB)

I’ll be glad to have some orientation, thank you

Hi @vzampa,


token == score - response + bonus

you basically ask Python “Is token the same as score - response + bonus?”, which it can’t answer because “token” does not exist so far (is not defined). If you want to define token as score - response + bonus, you have to use

token = score - response + bonus