Skip to content Skip to sidebar Skip to footer

Arthimatic Quiz Not Accepting Correct Answers

I am attempting to make an arithmetic quiz, but have run into this issue: Even if I input the correct answer, it seems to ignore the correct answer code and go straight to the inco

Solution 1:

3 is not equal to "3". The result of a call to input (in Python3) is a string, not a number.

Call int on the user input

...

ans1 = input("What is " + str(num1) + " multiplied by " + str(num2) + "? ")
ans1 = int(ans1)

...

Solution 2:

ifint(ans1) == correct1:
    print("Correct! ")
else:
    print(" Incorrect. ")
    print("  The correct answer was " + str(ans1))

You must compare numbers with numbers. You were comparing '3' vs 3

Post a Comment for "Arthimatic Quiz Not Accepting Correct Answers"