title: Python - While loops simple
body: <p>I am trying to write a function that calculates the number of days a species of bacteria takes for its initial population to reach its final population given that each day its population doubles. My code is;</p>
  
  <pre><code>def num_doublings(initial_population, final_population):
     time = 0
     while initial_population &lt; final_population:
         time+= 1
         initial_population = initial_population * 2
         print(time)
  </code></pre>
  
  <p>This prints each day, but I want it to only print the total number of iterations it takes for the while loop to stop. The output of my code when the function is called with <code>num_doublings(2, 8)</code> is</p>
  
  <pre><code>1
  2
  3
  </code></pre>
  
  <p>but I only need it to output 3. How do I fix this ?</p>