Question: Scenario You are completing some code, but you have an unhandled error. What do you do to make sure that the error doesn't stop your
Scenario
You are completing some code, but you have an unhandled error. What do you do to make sure that the error doesn't stop your program prematurely?
Aim
In this activity, we will practice handling errors. The code in Snippet throws an error.
The following code throws an error:
import random
printrandomrandinteger
Snippet
Identify and handle the error so that when it occurs, the message is printed to the terminal.
Steps for Completion
Go to your main.py file.
Take the code block from Snippet and amend to it so that it catches the error, using a try... except block.
Within the try... except block make the exception look for an AttriubuteError and print Double check the attributes in your code and try again.
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
