Python loop not cooperating
<p>I'm trying to create a loop for the given problem. I need help; it's not printing the way it should.</p>

<blockquote>
  <p>Given positive integer num_insects, write a while loop that prints
  that number doubled without exceeding 100. Follow each number with a
  space. </p>
  
  <p>Ex: If num_insects = 8, print:</p>

<pre><code>8 16 32 64
</code></pre>
</blockquote>



<p>Here's what I have</p>

<pre><code>num_insects = 8 # Must be &gt;= 1

print(num_insects, '', end='')

while num_insects &lt;= 100 :

     num_insects = num_insects * 2

     print(num_insects,'', end="")
</code></pre>

<p>This code prints the number 128 even thought the loop is set to end after 100? Why is that?</p>

<p>the <code>print</code> function implicitly adds a newline:
<a href="https://docs.python.org/2/library/functions.html#print" rel="nofollow">https://docs.python.org/2/library/functions.html#print</a></p>

<p>You can pass an alternative ending with the <code>end =</code> argument; try passing <code>None</code> or <code>' '</code> and see if that gets you a result that you like better.</p>

python