I'm trying to create a loop for the given problem. I need help; it's not printing the way it should.
Given positive integer num_insects, write a while loop that prints that number doubled without exceeding 100. Follow each number with a space.
Ex: If num_insects = 8, print:
8 16 32 64
Here's what I have
num_insects = 8 # Must be >= 1
print(num_insects, '', end='')
while num_insects <= 100 :
num_insects = num_insects * 2
print(num_insects,'', end="")
This code prints the number 128 even thought the loop is set to end after 100? Why is that?