We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 477a73f commit 91e3557Copy full SHA for 91e3557
1 file changed
codes_in_Aug2025/Advance python/finally.py
@@ -0,0 +1,17 @@
1
+# finally is mainly used in the context of exception handling in Python.
2
+# mainly under functions.
3
+
4
+def divide_numbers(a, b):
5
+ try:
6
+ result = a / b
7
+ except ZeroDivisionError:
8
+ print("Error: Division by zero is not allowed.")
9
+ return None
10
+ else:
11
+ print(f"{a} divided by {b} gives: {result}")
12
+ finally:
13
+ print("Execution of divide_numbers completed.")
14
15
+divide_numbers(10, 2)
16
17
+divide_numbers(10, 0)
0 commit comments