Loops are utilities that every programming language has. With the help of loops, we execute tasks or statements that are repetitive in nature, which, without loops, would take up lots of lines of code. This, in a way, defeats the purpose of having a programming language in the first place. If you are familiar with Java, C, or C ++, you might have already come across while, for, and do...while loops. Python is pretty much the same, except that it doesn't support do...while loops. Thus, the loops that we are going to study in the following section in Python are the following:
- while loop
- for loop