# get NameError information.
try:
i += 1
except NameError:
print("i is not definition.")
finally:
print("Now! handling this error.")
# get ValueError and TypeError and NameError information.
try:
i += a
except (NameError, ValueError, TypeError):
print("Name 'i' is not defined."
"'a' not a type.")
finally:
print("Now! handling this error.")
# get many kind information.
try:
print(1/0)
except ZeroDivisionError as error:
print("0 not as divisor: %s" % error)
finally:
print("Now! handling this error.")
# Capture any exceptions.
try:
a = 123
a.append(456)
except Exception as error:
print("This Error: %s" % error)
finally:
print("Now! handling this error.")