I would like to continue my loop if the called method throws an exception. This is a simple example,my actual code is pretty complicated and do not want to put error handling in all the called methods.
list_of_lists = [['hammerhead', 'great white', 'dogfish'],[0, 1, 2],[9.9, 8.8, 7.7]]
def parse(item):
item / 1
for list in list_of_lists:
for item in list:
try:
parse(item)
except ValueError:
break
This throws an exception, as soon as it hits the parse method. I was hoping that there is a way, that it just moves on to continue my loop. (outer loop)
TypeError. Tryexcept (ValueError, TypeError):to catch that as well.except:without giving is a specific error (or list of errors) to handle?continuewould be better thanbreakif you don't want to end execution on the inner list.