Introduction to Programming using Python 1st Edition

Published by Pearson
ISBN 10: 0132747189
ISBN 13: 978-0-13274-718-9

Chapter 13 - Files and Exception Handling - Section 13.9 - Defining Custom Exception Classes - Check Point - MyProgrammingLab - Page 463: 13.21

Answer

The program will print : Index out of bound

Work Step by Step

Inside the main function's try block function f will be called. In the try block of function f the print statement will try to print the element at 3rd index of the string, but the length of string is only 3 so the index is out of bound. There is no except block to handle IndexError in function f so this error will move to try block of main function. This try function have an except block to handle IndexError so the control will go there and Index out of bound will be printed.
Update this answer!

You can help us out by revising, improving and updating this answer.

Update this answer

After you claim an answer you’ll have 24 hours to send in a draft. An editor will review the submission and either publish your submission or provide feedback.