- 2
What is different between "While loop" and " For loop" in python.
5 Answers
+ 6
Thet Paing Htun ,
since you have not started any tutorial in sololearn, it would be a good idea to start learning python now.
both requested loops are described in the tutorial, and there are also exercises to get familiar with this topic.
happy coding!
+ 3
for loop is when you know how many iterations. While loop is when you don't
+ 2
for loop is: "FOR this many times, do that"
while loop is: "WHILE this, do that"
they're used for different cases and usually come down to preference. in C, the statements:
while (1) {}
AND
for (;;;) {}
create infinite loops
+ 2
For loop allows a programmer to execute a sequence of statements several times,
While loop allows a programmer to repeat a single statement or a group of statements for the TRUE condition.