Your checkAnswer()
function returns a tuple:
def checkAnswer(number1, number2, answer, right): if answer == number1+number2: print 'Right' right = right + 1 else: print 'Wrong' return right, answer
Here return right, answer
returns a tuple of two values. Note that it’s the comma that makes that expression a tuple; parenthesis are optional in most contexts.
You assign this return value to right
:
right = checkAnswer(number1, number2, answer, right)
making right
a tuple here.
Then when you try to add 1
to it again, the error occurs. You don’t change answer
within the function, so there is no point in returning the value here; remove it from the return
statement:
def checkAnswer(number1, number2, answer, right): if answer == number1+number2: print 'Right' right = right + 1 else: print 'Wrong' return right