How to run the loop again with range change based on ‘if statement’?


#1

let us say.
a = 1
b = 10
for i in range(a, b):
print(i)
if i == 5:
a +=1 # and run loop again.
How would I increase a by 1 and run the loop again?
Is there any way?


#2

That sounds like a loop inside a loop (known as nesting). Have you tried that?


#3

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.