You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+23Lines changed: 23 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -3230,6 +3230,29 @@ Generally, every compiling process have a two steps.
3230
3230
3231
3231
<details>
3232
3232
<summary>Explain Exception Handling and how to use it in Python</summary><br><b>
3233
+
3234
+
**Exceptions:** Errors detected during execution are called Exceptions.
3235
+
3236
+
**Handling Exception:** When an error occurs, or exception as we call it, Python will normally stop and generate an error message.</br>
3237
+
Exceptions can be handled using `try` and `except` statement in python.
3238
+
3239
+
**Example:** Following example asks the user for input until a valid integer has been entered. </br>
3240
+
If user enter a non-integer value it will raise exception and using except it will catch that exception and ask the user to enter valid integer again.
3241
+
3242
+
3243
+
```py
3244
+
whileTrue:
3245
+
try:
3246
+
a =int(input("please enter an integer value: "))
3247
+
print(a)
3248
+
break
3249
+
except:
3250
+
print("Ops! Please enter a valid integer value.")
3251
+
3252
+
```
3253
+
3254
+
For more details about errors and exceptions follow this [https://docs.python.org/3/tutorial/errors.html](https://docs.python.org/3/tutorial/errors.html)
0 commit comments