I'm new to programming and I'm trying to teach myself Python. I've started to write a little flashcard script. My idea is that the user is presented with a problem and is prompted to submit an answer. If the answer is incorrect the user is prompted to try again, an so on until the correct answer is entered. So far it works as planned, but I don't know how to make it start over again after the correct answer is entered. I suppose I'll also need to include some means of allowing the user to exit the game, which I also don't know how to do so if you want to throw in a suggestion about that I'd appreciate it. :-)
PS - If my code is lame I'm open to suggestions. But I'm mainly looking for an answer to my original question(s). This is my first foray into coding so I'm sure as time goes on I'll get better at writing more elegant code.
Thanks!
def add():
from random import randint
a = randint(1, 5)
b = randint(1, 5)
c = a + b
print a, '+', b
print 'What\'s the sum?'
d = input()
while d != c:
print 'Wrong, try again!'
d = input()
else:
print "Correct!"