How is exception handling implemented in Python?
Correct answer
A. try-except block
13 views
A. try-except block
13 views
Exception handling in Python uses the try-except block. Risky code goes in try; if an error occurs, the matching except clause runs instead of the program crashing. Optional else and finally clauses can follow.
Other languages use try-catch and throw; Python's equivalents are except and raise.
Want more practice? Try the full set of Computer Science MCQs on MCQsExam.com.
Not sure why the answer is A? Ask here and get an explanation.