Thank you. Problem solved.
I suspect your problem is the
score variable, which you use within the
ans function, but it is declared outside. (The error message should tell you the variable that is undefined.)
There are several possible solutions. Probably the easiest is to pass the current value of
ans as well as the correct answer
x and have it return the new value of score, so you would call it like:
score = ans(x, score)