Starting off by saying I'm completely new to python, I have to do a school project and I'm stuck with this part of the code. Pretty much, the requirements are being met to go through with the IF statement (the user input is equal to the answer, I'm sure of that) and the system is skipping straight to ELSE. I'm not sure if I'm just blind and it's a simple formatting problem or if it's something else I'm missing.
while valid == False:
topic = input().lower()
if topic == "addition":
print ("You have selected Addition!")
valid = True
ARand1 = randrange(1, 200)
ARand2 = randrange(1, 200)
question_answer = ARand1 + ARand2
print ("Question",questions_asked,":")
print ("What is",ARand1,"+",ARand2,"?")
users_answer = input("Please input your answer")
if users_answer == (question_answer):
print ("Correct!")
total_score += 1
questions_asked += 1
else:
print ("Incorrect!")
questions_asked += 1
print (questions_asked)
elif topic == "subtraction":
print ('You have selected Subtraction!')
valid = True
SRand1 = randrange(100, 200)
SRand2 = randrange(1, 100)
answer = SRand1 - SRand2
print ("Question",questions_asked,":")
print ("What is",SRand1,"-",SRand2,"?")
The part I'm getting stuck on is the second if statement (if users_answer == (question_answer):). It completely skips the IF and goes straight to the ELSE, even though the condition is met.
Apologies if it's something simple or if this poorly written, again I was just introduced to Python a few weeks ago.