exceptions unforeseen errors can occur in program during run time due to faulty code or invalid input consider the following sample code segmentwhich attempts to access non-existent element of listmylist print mylist when this code is executedthe program aborts and the following message is displayedtraceback (most recent call last)file ""line in indexerrorlist index out of range the last line in the message provides information as to the type of run-time error that caused the program to abort in this casethere are only four elements in the list numbered and thus subscript is out of range pythonlike many other high-level programming languagesraises an exception when an error occurs an exception is an event that can be triggered and optionally handled during program execution when an exception is raised indicating an errorthe program can contain code to catch the exception and gracefully handle it when an exception is not handledthe program will abort as was the case in our example above catching exceptions consider the following example in which we want to extract an integer value from the user with the input(functionvalue intinput("enter an integer value"