from random import *
for i in range(5):
x = randint(1, 2)
y = randint(1, 2)
sum = float(x) + float(y)
for i in range(2):
print (x , end =" "),
print ('+', end =" "),
print (y)
a = input('\n')
if a == sum: # this should let it know if it is right.
print ('Good job')
break
else:
if i<1: print ('Try again')
elif i==1: print ('Wrong, the answer is, %s.' % sum)
My code is supposed to ask an addition question and be able to tell if you are wrong or right. Currently, it says everything is wrong. I don't understand why it does this.
Aucun commentaire:
Enregistrer un commentaire