Python for loop with example
Python for loop - Here we will discuss the python for loop, and how we will write that in python for loop syntax and code. Python for loop is one of the basic step, if you are learning python basics.
Before Proceed, lets first understand what is for loop, why we use loop and what are the advantages of using for loop.
For Loop
Before learning for loop in python, In general term, if we say, For loop is iteration of some code which execute repeatedly with some specific condition. For example, if we want to print the no. from 1 to 10, we can print this by using for loop, where we know the condition that we have to print only no. from 1 to 10.
General flow chart of for loop is
Conclusion from the above flow chart diagram
- For loop needs some initialize variable to start with.
- After that it will check, if particular condition is satisfied or not.
- If yes, then it will execute the particular statements inside for loop.
- It will continue to execute the steps, till condition is satisfied.
- If condition is not satisfied