try:
i = int("string")
except ValueError as e:
print(e)
print("continued on")
j = int(9.0)
The point of the 'try' block is to encapsulate the code you want to *stop* executing if an exception is raised. If you want code to be run regardless of whether an exception is raised, move it past the try-except.
To be fair, I suspect the issue was there were two calls to int() there that might raise a ValueError, and the OP wanted to catch them with one except, so you would need to do somethign like:
try:
i = int("string")
except ValueError as e:
print(e)
print("continued on")
try:
j = int(9.0)
except ValueError as e:
print(e)
Which can seem a bit verbose, but in fact, there are a number of ways one might want to proceed with/without an error, and the current
except, finally, else options cover them all in a clearly defined way.
Christopher Barker, Ph.D.
Oceanographer
Emergency Response Division
NOAA/NOS/OR&R (206) 526-6959 voice
7600 Sand Point Way NE (206) 526-6329 fax
Seattle, WA 98115 (206) 526-6317 main reception
Chris.Barker@noaa.gov