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
13
13
14
14
- ** ` raise ` Statement** : You can use the ` raise ` statement to manually trigger an exception if a certain condition occurs.
15
15
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
+
16
38
## Example of Exception Handling
17
39
18
40
``` python
32
54
finally :
33
55
# Always executes, regardless of exceptions
34
56
print (" Execution complete." )
35
- ```
57
+ ```
You can’t perform that action at this time.
0 commit comments