CodesJava

Easy learning with example program codes

Python while loop


Python While Loop:

Python While Loop is a loop statement which can be used in various forms to execute a block of code continuously as long as the condition of the loop is true, and stops only when the condition fails. These are:

While Loop :

While loop is used to execute a group of action as long as the specified condition is true.

Syntax:

while (condition):

code to be executed if the condition is true

Nested While Loop :

Nested While loop is While loop inside a While loop and so on which is used to run multiple loop conditions.

Syntax:

while (condition):

while (condition):

                        code to be executed if the condition is true

Example:
//pythonexample.py

i = 0
while(i <= 20):
   print i
   i+=1

Output:

Sign Up/ Sign In
Ask a Question


Copyright © 2018 CodesJava DMCA.com Protection Status SiteMap Reference: Java Wiki