English

On giving the "raise syntaxError("HI")" command on Python shell, no exception is raised because the right way to write is:

Advertisements
Advertisements

Question

On giving the "raise syntaxError("HI")" command on Python shell, no exception is raised because the right way to write is:

Options

  • raise syntaxError("HI")

  • raise SyntaxError("HI")

  • raise SyntaxErrorException("HI")

  • raise syntaxErrorException("HI")

MCQ
Advertisements

Solution

raise SyntaxErrorException("HI")

Explanation:

The right syntax error exception to throw is SyntaxErrorException ("HI").

shaalaa.com
Raising Exceptions in Python
  Is there an error in this question or solution?
Share
Notifications

Englishहिंदीमराठी


      Forgot password?
Use app×