B. try block
A try block can be used to try to execute a piece of code and handle any potential errors that may arise, such as if the user enters letters instead of a number. With a try block, George can catch the error and prevent the program from crashing.
George is creating a program that will ask the user to input their grade in school. George wants to prevent the program crashing if the user enters letters instead of a number. Which of the following can be used?
A. for loop
B. try block
C. ValueError signifier
D. trace table
1 answer