Python if statement always printing incorrect -
i trying make algebra program if type correct answer, prints incorrect
x= random.randrange(1, 100) x2 = random.randrange(1, 100) answer = input('if x + ' + str(x2) + ' = ' + str(x + x2) + ' x equal to? ') ranswer = x + x2 if answer == ranswer: print('correct') else: print('incorrect')
nvm guys stupid shouldve done ranswer = x :p
x= random.randrange(1, 100) x2 = random.randrange(1, 100) answer = input('if x + ' + str(x2) + ' = ' + str(x + x2) + ' x equal to? ') if int(answer) == x: print('correct') else: print('incorrect')
as malik says, had problem in logic. fixed that, , cast answer
variable integer compare properly.
Comments
Post a Comment