running code if try statements were successful in python
You are looking for the else
keyword:
try:
#code that might fail
except SomeException:
#error handling if code failed
else:
# do this if no exception occured
You want else
:
for i in [0, 1]:
try:
print '10 / %i: ' % i, 10 / i
except:
print 'Uh-Oh'
else:
print 'Yay!'