Deals Of The Week - hours only!Up to 80% off on all courses and bundles.-Close
The for loop
The while loop
12. The difference between for and while loops
Nested loops
break and continue


Excellent! To sum up this section, let us say a few words about the difference between for and while loops.

Although for and while loops can be often used interchangeably, the main conceptual difference is that for loops are executed a specific number of times, whereas while loops are executed until a given condition turns false.

The rule of thumb is to use while loops when you can't predict the specific number of iterations. Otherwise, use for loops.


Click Next exercise to continue.