I have some code which asks the user to guess the answer to a calculation, and then either tells them they are correct or tries to identify where they went wrong. I have used a while loop in this but sometimes it gets stuck, is there a way to add a counter to the guesses taken, and to break the while loop after 5 incorrect guesses? Here is a section of my code so far:
#define correct answer for A
Ac=L*xm
#ask user to work out A (monthly interest * capital)
while True:
A= raw_input("What do you think the monthly interest x the amount you are borrowing is? (please use 2 d.p.) £")
A=float(A)
#tell user if they are correct or not
if A==round(Ac,2):
print("correct")
break
elif A==round(L*x,2):
print("incorrect. You have used the APR rate, whic is an annual rate, you should have used this rate divided by 12 to make it monthly")
continue
elif A==round(L/(x*100),2):
print("incorrect. You have used the interest rate as a whole number when you should have used it as a decimal, and divided it by 12 for the monthly rate")
continue
else:
print("Wrong, it seems you have made an error somewhere, you should have done the loan amount multiplied by the monthly rate")
continue