1.

Can one block of except statements handle multiple exception?(a) yes, like except TypeError, SyntaxError [,…](b) yes, like except [TypeError, SyntaxError](c) no(d) none of the mentionedThe question was posed to me in an internship interview.I'd like to ask this question from Exception Handling in section Classes and Objects, Inheritance, Polymorphism, Encapsulation and Exception Handling of Python

Answer»

The correct option is (a) yes, like except TYPEERROR, SYNTAXERROR [,…]

EXPLANATION: Each type of exception can be specified directly. There is no need to PUT it in a LIST.



Discussion

No Comment Found

Related InterviewSolutions