I'm trying to gradually increase the lower boundary of a range during a for loop. This is supposedly how it would work (I'm new to Python so assume complete ignorance):
start = 0
reset = bool
for i in range(start, 6):
print(i)
if i > 4:
reset = True
if reset == True:
start += 1
i = start
Ideally, this would have outputs like:
0, 1, 2, 3, 4, 5 reset
1, 2, 3, 4, 5 reset
2, 3, 4, 5 *reset
I tried the above code but to no avail..
etc.
This must be possible to do, no? Note I'm trying to use this in a much more complicated nested 'for' loop and so ideally the solution would work with that.
Thanks in advance!
range(start, 6)creates an iterator based upon the initial start value which i is sequencing through. Changing start afterwards has no affect on this sequence of numbers. You need a while loop.whileandforloop for this.