Unit9ErrorsandExceptionsHandling
Unit9ErrorsandExceptionsHandling
Handling
Unit 9
CCS 1400
Differentiate
try, except,
else, and finally
blocks
Create a
program that
handles errors or
exceptions
try and except Basic
Terminology and Syntax
▪ Error
− a problem in a program that stops it from completing its
task
▪ Exception
− a condition that disrupts the normal execution of the
program
▪ except block
− handles the error
▪ else block
− executes code when there is no error
▪ finally block
− executes code, regardless of the result of the try and
except blocks
▪ raise keyword
− used to raise an exception