Which of the following statements is used to handle exceptions in Python?
Correct answer
D. both 'try' and 'except'
19 views
D. both 'try' and 'except'
19 views
In Python, the 'try' and 'except' statements are used together to handle exceptions or errors that occur during program execution. The 'try' block contains the code that may raise an exception, and the 'except' block catches and handles the exception if it occurs.
Not sure why the answer is D? Ask here and get an explanation.