While Loop
In this body is executed until condition is true. Once the condition becomes false then control comes out the loop.
Syntax 

while condition:
Body of while loop

while loop
 
e.g.

i = 10
while i>5:
print i
i=i-1

Output 
10
9
8
7
6
 
For Loop
For loop executes the sequence of code according to the specified times and conditions.
Syntax

for variable in sequence:
Body of for loop

for loop
 
e.g.

i=1
for i in range(1,8):
print 2*i

Output 
2
4
6
8
10
12
14
 
Nested Loop 
Loop defined within another loop is known as nested loops.
Syntax 

for condition1:
for condition2:
Body of for loop

This blog will help you get a better understanding of Automate Your Coding with Python!

Leave a Reply

Your email address will not be published. Required fields are marked *

Solve : *
11 + 24 =