What makes a loop err loop?
Have you noticed that a while loop has a condition like a if statement? No? Oh dear….
A loop will run while the condition is true. The second the loop becomes false it will stop.
x = 10
while x > 0:
print x
x = x - 1
This loop will start at 10 and stop at 0. The condition, x>0, will be true initially. As the loop runs x will decrease by one until x is no longer bigger than 0. Try the above code to see just how amazing a computer can look when counting backwards!
Change the above code so it will stop when it gets to 5.
Output: (clear)











