Exception is
an event that disrupts the normal flow of execution. Even though statements in
your program are syntactically correct, they may cause an error.
>>> 10/0 Traceback (most recent call last): File "<stdin>", line 1, in <module> ZeroDivisionError: division by zero >>> >>> tempList=[] >>> tempList[20] Traceback (most recent call last): File "<stdin>", line 1, in <module> IndexError: list index out of range
Observer
above snippet, ‘10/0’ causes ZeroDivisionError. When program tries to access 20th
element of tempList it causes IndexError.
No comments:
Post a Comment