Python Loops
In any of the programming language the flow of the programs is sequential by default. If any condition occur that you may need to alter the flow of the program in a sense that a specific part of the program may need to be repeated a number of times then in that case loops are used.
There are various types of loops that are can repeat some specific code to a number of times. For better understanding of the working of loop consider the following diagram which represent the working of a loop statement.
Why we use loops in python?
The process of looping converts the complex statement into simpler form to make it easy. Looping also enables us to change the flow of a program i.e. some condition may arrive that specific part of the code may need to be repeated many or finite number of tims then. Foe e.g. if we want to print first 10 natural numbers then in place of writing the print statement 10 times we can use loop for that upto 10 iterartions.
Advantages of loops
There are the following advantages of loops in Python.