In general, statements are performed sequentially: In a function, the first statement is executed at first, followed by the second, and so on. There may be a situation when it's important to execute a block of code various numbers of times.
Programming languages provide a lot of control structures that allow for more complicated execution paths.
Python programming language provides the various categories of loops to handle looping requirements which are described below:
|Sr.No.||Loop Type & Explantation|
Repeats a statement or group of statements while a given condition is TRUE. It tests the condition before executing the loop body.
Executes a sequence of statements various times and abbreviates the code that manages the loop variable.
It is possible for you to use one or more loop inside any another while, for or do..while loop.
Loop Control Statements
Loop control statements transform execution from its normal sequence. When execution leaves a scope, all automatic objects that were created in that scope are demolished.
Python supports various control statements which are described as follows:
|Sr.No.||Control Statement & Explanation|
Terminates the loop statement and transfer execution to the statement instantly following the loop.
Causes the loop to avoid the remainder of its body and immediately retest its condition before reiterating.
The pass statement in Python is beneficial when a statement is needed syntactically but you do not want any command or code to execute