Question: Write code to do the following: 2 a . Ask the user to input an integer and save it as variable i . The user

Write code to do the following: 2a. Ask the user to input an integer and save it as variable i. The user may or may not enter an integer. 2b. If the user enters a non-integer value, raise ValueError exception, display the default error message and exit the program. 2c. If the use enters an integer i, find the element with index i in list2 and print it. If the index is out of range, raise an exception and display an appropriate error message (not default message).2d. Ask the user to enter an integer j between 0 and n-1, where n is the number of elements of list1. You can assume that they will enter a valid integer in the proper range. 2e. Then calculate list1[j]+list2[j] and print the result with a suitable message. If an exception occurs, catch the exception and display the default error message. Add a finally clause the prints Done!

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!