We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent f13d6c2 commit 0f12786Copy full SHA for 0f12786
Python/Exceptions/Main.py
@@ -0,0 +1,34 @@
1
+try:
2
+ number = int(input("Enter a number: "))
3
+ print(number)
4
+
5
+except:
6
+ print("Invalid Input, please enter number!")
7
8
9
+x = 0
10
11
12
+ print(1/x)
13
14
+except ZeroDivisionError:
15
+ print("Cannot divide by zero!")
16
17
18
+var_dict = {"average" : "5.0"}
19
20
21
+ print(f"Average is {var_dict['average']}")
22
23
+except KeyError:
24
+ print("Key not found in dictionary!")
25
26
+except TypeError:
27
+ print("You cannot divide string values!")
28
29
+else:
30
+ print("No exceptions occurred.")
31
32
+finally:
33
+ print("Execution completed.")
34
Python/Exceptions/TryAndCatch.py
0 commit comments