Hello all,
i am a beginner at programming. I am trying to code a little program for my daughter t help her learn her multiplication. Everything works fine but if instead of putting a number for input, you just press enter, i get an error and it crash. I tried to find a solution to put a string to ask a good answer but just cant get it. Can someone help me please
Here is the code:
i am a beginner at programming. I am trying to code a little program for my daughter t help her learn her multiplication. Everything works fine but if instead of putting a number for input, you just press enter, i get an error and it crash. I tried to find a solution to put a string to ask a good answer but just cant get it. Can someone help me please
Here is the code:
Code:
import random
test = 0
note = 0
while test < 20:
multipliant = random.randrange(1,13)
multiplieur = random.randrange(1,13)
quotient = multipliant*multiplieur
print `multipliant` + " X " + `multiplieur` + " = "
try:
reponse = input('Votre réponse ?:')
except:
print "Entrez une réponse :"
else:
test = test + 1
if reponse == quotient:
note = note + 1
print "Bravo"
else:
print "Desoler la bonne réponse est: " + `quotient`
reponse = input("Votre réponse ?:")
print "Vous avez réussi " + `note` + " questions sur 20"
print `note*5` + "%"