I have got the following piece of code, so that while any exception occurs, re-do this loop, instead of jumping to the next loop. Please note the pseudo code here does work as intended:
for cl in range(0, 10):
try:
some_function(cl)
except :
cl -= 1
My initiative was that once something go wrong, do it again. Obviously, this is not a working idea. So given the assumption that the for loop and range function being used, how to implement the control that I described?
Thanks
some_function()will eventually succeed? Because otherwise, you will have an infinite loop.exceptshould only be used with specific exceptions, as otherwise you are likely to catch things you don't mean to and obscure bugs.