Answered step by step
Verified Expert Solution
Question
1 Approved Answer
try and except Coding Problem 3.5.8 (Advanced) (External resource) (1.0 points possible Listindices.py Submit Run Grades Reset 1 a list [1, 2, 3, 4, 5]
try and except
Coding Problem 3.5.8 (Advanced) (External resource) (1.0 points possible Listindices.py Submit Run Grades Reset 1 a list [1, 2, 3, 4, 5] Console output wil be displayed here 2 lIstindex 7 5 You may modify the lines of code above, but don't move them! 6 #When you Submit your code, we'11 change these lines to 7 #as sign different values to the variables 9 tin this,Problem, we're going to use some unfamiliar syntax 18 You'll learn more about this syntax in Unit 4. For now, 11 #though 12 #need to 13 #error with the values supplied above 14 # 15 #Revise this code so that this error is caught, and the 16 don't need to understand the syntax. Al1 you is that right now, this code will cause an message "Invalid index!!" is printed. HOtever, your revision 17 #must meet these requirements, too: 18 # 19 #-If the values of the variables above are changed so 20 # that the error doesn't occur, the 21 # the program should behave same way that it does now 22 # -The two first and last lines, "Accessing index and 23 "Done!", should print whether or not an error occurs 24 #-If a xdifferent" error occurs from the one that arises 25 # initially, your code should instead print "unknown 26# error ! 27 # 28 HINT: You on't be able to do this without running the code 29 #first and seeing what the error is. So, try it out first! 30 31 #Revise this code: 32 print("Accessing index..." 33 result = a listlist index 4 printvalue at index:", result) 35 print("Done!" 36 37 38 39 48 41Step 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