Back Navigation Next Navigation Video 5: Conditionals (page 8 of 10)

Another form of conditional execution is the try & except conditional. This conditional execution captures certain expected and unexpected errors. If a statement in the "try" conditional throws an error, then the except block executes. The statements in the except clause or except block are ignored if there is no error in the try block.

Essentially, Python starts by executing the sequence of statements in the try block. If all goes well (i.e., no statement or expression throws an error), it skips the except block. If an error occurs in a statement or expression in the try block, Python jumps out of the try block and executes the statements in the except block.