Run-Time Errors:
occurs when the program is running (e.g division by 0)
or using a undefined variable
Exception Handling:
detect cases where r.t errors would occur
Specific Exception Handling:
specifying the error type
argument of an exception:
you can capture an exception's argument by supplying a variable in the except clause
e.g
answer = raw_input("choose a, b, or c:")
if answer != "a" and answer !="b" and answer !="c":
raise ValueError("Question 1: Invalid Input: please enter a, b, or c")
else:
print "thank you"
except ValueError, errorvar:
print errorvar
Created By
Metadata
Favourited By
Comments
No comments yet. Add yours below!
Add a Comment