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

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.