What are the differ…
 
Notifications
Clear all

[Solved] What are the different kinds of loops in python?

5 Posts
6 Users
1 Likes
607 Views
0
Topic starter

Explain

riyaponraj riyaponraj 20/03/2023 4:08 pm

@natasha1305 there is a for loop along with its variants such as for loop with range, nested for loop and there is while loop.

4 Answers
0

In Python, there are three types of loops to handle the looping requirement: for loop, while loop, and nested loops.

for loop: A for loop is used for iterating over a sequence (that is either a list, a tuple, a dictionary, a set, or a string). It executes a set of statements, once for each item in a list, tuple, set, etc

while loop: A while loop is used to execute a block of code repeatedly as long as the specified condition is true

Nested loops: A nested loop is a loop inside a loop. The “inner loop” will be executed one time for each iteration of the “outer loop”

1

There are Three types of loops in python

 1. For loop:- It is used to iterate over data sequence like list,arrays,tuples etc.

2. While loop:-It continually executes the statements (code) as long as the given condition is TRUE.

3. Nested loop:-Nested loops mean using a loop inside another loop. We can use any type of loop inside any type of loop.

0

The three types of loops in Python programming are while loop, for loop, and nested loops.

0

Mainly there are three kinds of loops in python-

1.For Loop

2.While Loop

3.Nested Loop

Share: