File tree Expand file tree Collapse file tree 1 file changed +23
-1
lines changed
Expand file tree Collapse file tree 1 file changed +23
-1
lines changed Original file line number Diff line number Diff line change @@ -13,6 +13,28 @@ Exception handling helps prevent our program from crashing when something goes w
1313
1414- ** ` raise ` Statement** : You can use the ` raise ` statement to manually trigger an exception if a certain condition occurs.
1515
16+ # Common Types of Errors (Exceptions) in Python
17+
18+ Python provides many built-in exceptions to handle different types of errors that may occur during runtime.
19+
20+ ## ✅ Common Built-in Exceptions
21+
22+ | Error Name | Description |
23+ | ------------------------| -------------------------------------------------|
24+ | ` ZeroDivisionError ` | Raised when division by zero occurs (` 10 / 0 ` ) |
25+ | ` ValueError ` | Raised when an invalid value is used (` int("abc") ` ) |
26+ | ` TypeError ` | Raised when an operation is applied to an object of inappropriate type (` "a" + 5 ` ) |
27+ | ` IndexError ` | Raised when a sequence index is out of range (` list[10] ` ) |
28+ | ` KeyError ` | Raised when a dictionary key is not found |
29+ | ` NameError ` | Raised when a variable is not defined |
30+ | ` FileNotFoundError ` | Raised when a file or directory is not found |
31+ | ` ImportError ` | Raised when an imported module cannot be found |
32+ | ` AttributeError ` | Raised when an invalid attribute reference is made |
33+ | ` IndentationError ` | Raised due to incorrect indentation |
34+ | ` SyntaxError ` | Raised when the Python syntax is incorrect |
35+
36+ ---
37+
1638## Example of Exception Handling
1739
1840``` python
3254finally :
3355 # Always executes, regardless of exceptions
3456 print (" Execution complete." )
35- ```
57+ ```
You can’t perform that action at this time.
0 commit comments