Handling Exceptions
# It is possible to write programs that handle selected exceptions. Look at the following example, which prints a table of inverses of some floating point numbers: numbers = [0.3333, 2.5, 0, 10] for x in numbers: print x, try: print 1.0 / x except ZeroDivisionError: print '*** has no inverse ***'
1. | Simple exception handling example | ||
2. | Catch exception in a function | ||
3. | handle multiple exceptions | ||
4. | Demonstrates handling exceptions | ||
5. | Exception handlers handle Exceptions occur inside functions. |