samedi 25 avril 2015

python if statement always printing incorrect

I was trying to make a algebra program but even if i type the correct answer, it prints incorrect

x= random.randrange(1, 100)
x2 = random.randrange(1, 100)
answer = input('if x + ' + str(x2) + ' = ' + str(x + x2) + ' what is x equal to? ')
ranswer = x + x2
if answer == ranswer:
   print('correct')
else:
   print('incorrect')

Aucun commentaire:

Enregistrer un commentaire