well, look like there were some code but that is no more so I don't know what was wrong with that, but by your description maybe you need something like this:
def ask_user(question,answer):
"""ask the user some question and return if the expected answer was given """
return answer == input(question)
def trial(question,answer,chances=3):
"""repeatedly ask the user a question by a number of chances and return True
if the expected answer is given, otherwise return False"""
for i in reversed( range(chances) ):
if ask_user(question,answer):
return True
else:
print("wrong answer you have",i,"more chances")
return False
def test(trials,chances=3):
"""given a list of tuples of the form (question,answer) ask the user for
an answer to each question given him/her a number of chances in each
one and return True if all of them are answered correctly otherwise
return False at the first failure """
print("Welcome to this test, please answer the next few questions:")
for i,(q,a) in enumerate(trials,1):
print("questions #",i)
if not trial(q,a,chances):
return False
return True
def my_test():
my_trials=[("1+2= ","3"),
("translate 'home' to Spanish: ","casa"),
("what is the Answer to the Meaning of Life, the Universe, and Everything Else: ","42")
]
print("you pass the test" if test(my_trials) else "You fail this test")
this is fairly generic so you can define several tests reusing the given functions by just defining one like I did with my_test