Answered step by step
Verified Expert Solution
Question
1 Approved Answer
List value_list contains elements 'butter', 'rice', 'tea', and 'chocolate'. In the try block, integer list_index is read from input. The element at list_index of value_list
List value_list contains elements 'butter', 'rice', 'tea', and 'chocolate'. In the try block, integer list_index is read from input. The element at list_index of value_list is output. Complete the following tasks: Write an exception handler to catch ValueError and output 'int(): Input is not an integer.' Write an exception handler to catch IndexError and output 'List index should be between -4 and 3.' value_list = ['butter', 'rice', 'tea', 'chocolate'] try: list_index = int(input()) print(f'value = {value_list[list_index]}') # Your code goes here
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started