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

Popular posts from this blog

asp.net mvc - SSO between MVCForum and Umbraco7 -

Python Tkinter keyboard using bind -

ubuntu - Selenium Node Not Connecting to Hub, Not Opening Port -