Reputation:
x=4
for i in range(1, x):
try:
...
except:
x+=1
The range is
1
2
3
4
And then it stops.
I want the cap to be increased when the exception occurs.
Upvotes: 0
Views: 419
Reputation: 24100
If you want the loop limit to change dynamically, then you need to use a while
loop:
x = 4
i = 1
while i < x:
try:
...
except:
x += 1
Upvotes: 1