When writing a program, many things can go wrong. Sometimes these errors are your mistake in the code, other times, they are unavoidable, yet potentially harmful. In simple words, errors are something which Python doesn't like and will show its displeasure on by abruptly terminating the program.
Errors can be of two types:
1.Syntax errors
2.Errors which are encountered at runtime (Exceptions)
Exceptions occur during run-time. Your code may be syntactically correct but it may happen that during run-time Python encounters something which it can't handle, then it raises an exception. For example, dividing a number by zero or trying to write to a file which is read-only.
When a Python script raises exception, it creates an Exception object. If the script doesn't handle exception the program will terminate abruptly.
#python
#exception_handling
#crazytechlearner
0 Comments