Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in Python by (12.7k points)

I'm discovering issues in when I should utilize while loop or a for loop in Python. It would seem that individuals lean toward utilizing a for loop (less code lines?). Is there a particular circumstance which I should utilize either? Is it a matter of individual preferences? The codes I have perused so far made me think there are huge contrasts between them.

1 Answer

0 votes
by (26.4k points)

The for statement emphasizes through a collection or iterable object or a generator function

The while statement basically loops until a condition is False.

Click on this following link, if you want to know more details about for loop and while loop.

It isn't a preference. It's an issue of what your data structures are.

Join the python online course fast, to learn python concepts in detail and get certified.

Related questions

0 votes
1 answer
asked Sep 23, 2019 in Python by Sammy (47.6k points)
0 votes
1 answer
0 votes
1 answer
0 votes
1 answer
asked Oct 11, 2019 in Python by Sammy (47.6k points)
0 votes
1 answer
asked Aug 31, 2019 in R Programming by Ajinkya757 (5.3k points)

Browse Categories

...