Python try Keyword
try keyword is used in conjunction with the
except keyword and often the
finally keyword to wrap blocks of code
that may throw an error.
try: result = 10 / 0 except: print("Oops - division by 0!")
Oops - division by 0!
By wrapping the potentially error-prone code in a try...except block we are able to catch the exception, do something with it (eg record the error) and the continue on without the program halting due to the unhandled error.