Python Exception Handling – tccicomputercoaching.com
Exception in a code can also be handled. In case it is not handled, then the code is not executed further and hence execution stops when exception occurs.
Why use Exceptions?
Exceptions are convenient in many ways for handling errors and special conditions in a program. When you think that you have a code which can produce an error then you can use exception handling.
- ZeroDivisionError: Occurs when a number is divided by zero.
- NameError: It occurs when a name is not found. It may be local or global.
- IndentationError: If incorrect indentation is given.
- IOError: It occurs when Input Output operation fails.
- EOFError: It occurs when end of the file is reached and yet operations are being performed.
2. malicious code
3. except Exception1:
4. execute code
5. except Exception2:
6. execute code
9. except ExceptionN:
10. execute code
12. In case of no exception, execute the else block code.
Call us @ 9825618292
Visit us @ www.tccicomputercoaching.com