Certified Associate in Python Programming (PCAP) — Question 90
If you want to access an exception object's components and store them in an object called e, you have to use the following form of exception statement:
Answer options
- A. except Exception (e) :
- B. except e= Exception :
- C. except Exception as e:
- D. such an action is not possible in Python
Correct answer: C
Explanation
The correct answer is C, as 'except Exception as e:' is the proper syntax in Python for capturing an exception into a variable. Options A and B are incorrect because they do not follow the correct syntax for exception handling in Python. Option D is also incorrect because it is indeed possible to store an exception object in a variable.