title: How to add a counter to a while loop?
body: <p>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:</p>
  <pre><code>#define correct answer for A
  Ac=L*xm
  #ask user to work out A (monthly interest * capital)
  while True:
      A= raw_input(&quot;What do you think the monthly interest x the amount you are borrowing is? (please use 2 d.p.) £&quot;)
      A=float(A)
      #tell user if they are correct or not
      if A==round(Ac,2):
          print(&quot;correct&quot;)
          break
      elif A==round(L*x,2):
          print(&quot;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&quot;)
          continue
      elif A==round(L/(x*100),2):
          print(&quot;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&quot;)
          continue
      else:
          print(&quot;Wrong, it seems you have made an error somewhere, you should have done the loan amount multiplied by the monthly rate&quot;)
          continue
  </code></pre>