Loops in Python - What are loops and how to code while loop, for loop, nested loops in Python?

Loops are set of instructions that are continuously executed until the mentioned condition is met. 

Following are the types of Loops in Python - 

1. while Loop - 

General structure of while loop - 

while condition:

     statements

 

2. for Loop

General structure of for loop - 

for target in object: 

     statements 

else: 

     statements

 

Leave a comment

Filtered HTML

  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <blockquote> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Lines and paragraphs break automatically.

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.