var=input('Please enter a number not equal to 0: ')try:var=1/float(var)exceptZeroDivisionErrorase:print('Error: '+str(e))print('You had one job!')

Warning

This post does not cover what python exceptions are. If the above
code doesn't make sense you should check out this Introduction to Python
Exceptions from wiki.python.org before reading this post.

If you've fallen in love with Python you've no doubt discovered exceptions:

try:# do a thingexcept:# thing did not work,# do something else

They are endlessly useful and help one to avoid writing checks upon checks upon
checks before getting to the meat of your project. Just try a thing, catch the
error, keep on rolling (or fail gracefully).

As powerful as they can be, I have found a lot of folks (past me included) who
don't know how to find python exceptions and don't know how to write their own
exceptions! So let's do that.

Finding Exceptions

When writing exception handling code it's kosher to explicitly state which
error you expect.