title: Python: How to keep running program until some value becomes 0 and checking how long it takes
body: <p>I have the following code:</p>
  
  <pre><code>time_counter = 0
  for i in range(time_counter):
      if pred &gt; 0:
          prey, pred = prey*(1+A-B*pred), pred*1-C+D*prey)
      else:
          print time_counter
      time_counter +=1
  </code></pre>
  
  <p>The values for A, B, C, and D are fixed to 0.1, 0.01, 0.01, 0.00009. pred is 20 and prey is 1000. I'm trying to figure out how long it takes for pred to become 0 (as an integer, not float) and then display that time.</p>
  
  <p>Logically, I can think of it is starting the time at 0 and running the formula...if pred is greater than 0 than repeat and until pred is 0 or less than 0 to stop and display the time. Not sure what I am doing wrong.</p>
  
  <p>Please try to keep it basic. I'd like to be able to do it using a for loop with conditional statements and using Python 2.7 syntax.</p>
  
  <p>EDIT: Sorry if something was confusing. I want to count the time periods (which in this case would be the number of iterations) that the loop runs until pred is equal to 0. However, pred should be considered 0 once it is &lt; 1 so even 0.999 would be 0.</p>