-2

I am trying to make a math quiz on python, and I am trying not to use random. When I set user input to the answer of the problem and then try to run it, it says its wrong. Why? Here is apart of my code. When I answer '78' correctly, it says sorry that is not right.

def problem1():
    raw_input('36 + 42 = ')
    if input == '78':
        print('Correct!')
    else:
        print('Sorry that is not right.')
k.carr
  • 1

1 Answers1

2

You're calling raw_input, but not saving its returned string, which is the user's input. Then you're comparing the existing input function against "78" which will never be correct.

Just save the users input properly then use it in the comparison:

inp = raw_input('36 + 42 = ')
if inp == '78':
Carcigenicate
  • 43,494
  • 9
  • 68
  • 117