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: a Ask the user to input an integer and save it as variable i The user may or may not enter an integer. b If the user enters a noninteger value, raise ValueError exception, display the default error message and exit the program. c If the use enters an integer i find the element with index i in list and print it If the index is out of range, raise an exception and display an appropriate error message not default messaged Ask the user to enter an integer j between and n where n is the number of elements of list You can assume that they will enter a valid integer in the proper range. e Then calculate listjlistj 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
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
