A Display Name A Display Name - 3 months ago 7x
Python Question

Python - Test For Error

In my program, It sometimes encounters an error. The only way to stop the error, is to restart the program.

So how could I get python to know when there is an error?

Example - If there is an error, close down the program.

How do I do this - Thanks!


That is called exception handling. You should read about it.

The basic syntax is the following:

    code that might give an error (aka exception)
except TheExceptionExpected:
    thing to do if error happends