0
in very simple words what is the difference between for and while loop?
for and while loops
3 Answers
+ 4
In simple words, while loops keeps terminating the code inside it until it evaluates to false and for loop is used for performing operations on each item of the list or iterating it a given number of items.
Example 1:
while True:
print("Hello world") #this will print it repeatedly because the condition will remain always true.
Example 2:
for i in range(10):
print ("Hello world") #it will print Hello world ten times.
+ 2
for loop is for when you know how many times you want to loop. while loop is for when you dont.
+ 1
kk.thank you to both