
Patrick B. answered 01/13/21
Math and computer tutor/teacher
It depends on the problem at hand and the situation.
You can BREAK out of the for loop if a condition is met.
Remember that for loops require knowledge of how many times the loop must
execute. It requires either an array over which to iterate or some expression that
can be created from the RANGE function..
If you're doing numerical iteration, you can calculate how many sub-intervals your
function uses or how many steps it will take to cross the interval...
Here is an example
print("Hello world")
x=10
#loop technically goes from 10 to -10
for i in range(x,-x,-1):
print(i)
if (i==0):
break
print("BLASTOFF")