Python Loops
# Python2.x Python Loop Statements
This chapter will introduce you to Python's loop statements. Programs normally execute sequentially.
Programming languages provide various control structures that allow for more complex execution paths.
Loop statements allow us to execute a statement or group of statements multiple times. Here is the general form of loop statements in most programming languages:
!(#)
Python provides `for` loops and `while` loops (there is no `do..while` loop in Python):
| Loop Type | Description |
| --- | --- |
| (#) | Executes the loop body as long as the given condition is true, otherwise exits the loop body. |
| (#) | Repeats executing statements. |
| (#) | You can nest a for loop inside a while loop body. |
* * *
## Loop Control Statements
Loop control statements can change the order of statement execution. Python supports the following loop control statements:
| Control Statement | Description |
| --- | --- |
| (#) | Terminates the loop during statement block execution and exits the entire loop. |
| (#) | Terminates the current loop during statement block execution, skips the rest of the current loop iteration, and proceeds to the next iteration. |
| (#) | pass is an empty statement, used to maintain the structural integrity of the program. |
YouTip