Deals Of The Week - hours only!Up to 80% off on all courses and bundles.-Close
The for loop
2. Why we need loops
The while loop
Nested loops
break and continue


Suppose you want to write a program that prints numbers from 1 to 10. How can you do that? The naive approach is to do this:

print('Current value: 1')
print('Current value: 2')
print('Current value: 10')

But that's a lot of pointless typing! Computers are actually pretty good at doing repetitive things using so-called loops. Let's observe them in action.


Run the template code and observe what happens. As you can see, there are ten sentences in the output.