Errors and Exceptions Flashcards
1
Q
What are the syntax structures of raise and assert errors? Geben Sie ein Beispiel für AssertionError and TypeError.
A
try:
if i.isnumeric():
raise TypeError(“custom error message”)
assert condition == True, “error message if false”
except TypeError as e:
do something to handle the error
except AssertionError as e:
do something to handle the error