+ 1
How do one iterates to until a certain condition is fulfilled and then know exactly how many times the code underwent the loop?
5 Antworten
+ 3
You could create a variable and increase it it by one every iteration.
+ 1
A more pythonic way is to use enumerate.
0
Hi! You use a for loop to iterate through a collection, and a if statment in the loops body. When the if condition is true, you use ‘break’ to break the loop.
Read more about it in the Python courses on SoloLearn.
0
count=0
for i in range(5):
count+=1