title: Record how many times a while loop runs? - python
body: <p>Imagine this:</p>
  
  <p><em>You have a while loop</em></p>
  
  <p><em>You want to know how many times it ran</em></p>
  
  <p><em>What should you do???</em></p>
  
  <p>Now I hear you say, <em>what is the context?</em></p>
  
  <p><strong>Context:</strong>
  I am writing this program in Python which thinks of a number between 1 and 100, and you are to guess it. The guessing takes part in a while loop (please have a look at the code below) but I need to know how many guesses are made.</p>
  
  <p>So, this is what I need:</p>
  
  <pre><code>print("It took you " + number_of_guesses + " guesses to get this correct.")
  </code></pre>
  
  <p>This is the complete code at Gist: <a href="https://gist.github.com/anonymous/1d33c9ace3f67642ac09" rel="nofollow">https://gist.github.com/anonymous/1d33c9ace3f67642ac09</a></p>
  
  <p><strong>Please remember: I am using Python 3x</strong></p>
  
  <p>Thanks in advance</p>