Show Menu

Exception Handling Cheat Sheet by

exceptions

Main Exception Errors

Assertion Error
Raised if assert statement fails
EOFError
Raised if input reaches end of file
Import­Error
Raised if import module not found
KeyError
Raised if key is not in dictionary
IndexError
Raised if index is out of range
Keyboa­rdI­nte­rrupt
Raised if user stops program
NameError
Raised if variable is not found
Runtim­eError
Raised for non-ca­teg­orized types
 

Exception Statements

try:
Runs code and checks for errors
except:
If error occurs, handles all types of errors.
except exception:
If type of error occurs, handles error
finally:
Code that executes after TRY and/or EXCEPT statements

Download the Exception Handling Cheat Sheet

1 Page
//media.cheatography.com/storage/thumb/crystinvw_exception-handling.750.jpg

PDF (recommended)

Alternative Downloads

Share This Cheat Sheet!

 

Comments

No comments yet. Add yours below!

Add a Comment

Your Comment

Please enter your name.

    Please enter your email address

      Please enter your Comment.

          More Cheat Sheets by crystinvw