Are Python Exceptions runtime errors?

All python exceptions are not runtime errors, some are syntax errors as well.

If you run the given code, you get the following output.

File "C:/Users/TutorialsPoint1/", line 4
SyntaxError: invalid syntax

We see that it is syntax error and not a runtime error.

Errors or inaccuracies in a program are often called as bugs. The process of finding and removing errors is called debugging. Errors can be categorized into three major groups:

  1. Syntax errors 2. Runtime errors and 3. Logical errors

Syntax errors

Python will find these kinds of errors when it tries to parse your program, and exit with an error message without running anything. Syntax errors are like spelling or grammar mistakes in a language like English.

Runtime errors

If a program is free of syntax errors, it will be run by the Python interpreter. However, the program may exit if it encounters a runtime error – a problem that went undetected when the program was parsed, but is only revealed when the code is executed.

Some examples of Python Runtime errors −


  • division by zero
  • performing an operation on incompatible types
  • using an identifier which has not been defined
  • accessing a list element, dictionary value or object attribute which doesn’t exist
  • trying to access a file which doesn’t exist