Do-while loop


Do-while loop

The extended modification of while loop that is popularly utilized in computer languages is do while loop. This loop is efficient in monitoring condition subsequent to successful execution of the specific statement. This while loop is speedy in terms of execution. The outcome of Boolean condition is the basis of while loop utilization in order to duplicate a block of specific code. The running of code in specific while code is possible only if the statement utilized in while loop is verifiable. When an individual is actively programming, various situations are encountered that need the introduction of loops. Python has two amazing integrated functions that permits users to generate loops. These are “for” and “while”. Python ﴾do while loops﴿ successfully runs a code block until a statement is accurate while the working stops once evaluated as false. At a particular time, the condition is required to be termed as “false” otherwise the process will keep on going. The monitoring of condition in a specific loop occurs by our code at a particular running time of the while loop. It is observed that “do while” type of loop successfully executes a particular loop and afterwards assess a condition but “do while” types of loops are non‐existent in Python so the key focus here is on normally occurring while loops.

Example:

i = 1 x='knowledge2life' while True: print(x) i = i + 1 if(i > 5): break

OUTPUT:

knowledge2life
knowledge2life
knowledge2life
knowledge2life
knowledge2life