-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathday14.py
More file actions
55 lines (33 loc) · 1.32 KB
/
day14.py
File metadata and controls
55 lines (33 loc) · 1.32 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
"""Error handling in Python is a critical part of writing robust and reliable code. Errors, also known as exceptions, can occur for various reasons, such as invalid inputs, file not found, network issues, and so on. Python provides a way to handle these exceptions to prevent your program from crashing and to provide a better user experience. Here's an overview of error handling in Python :"""
# try,except,finally
# num1=int(input("Enter first number : "))
# num2=int(input("Enter second number : "))
# print(num1+num2)
# print("hello pragati ")
# try:
# num1=int(input("Enter first number : "))
# num2=int(input("Enter second number : "))
# print(num1+num2)
# except Exception as e:
# print(e)
# print("hello pragati ")
# try:
# num1=int(input("Enter first number : "))
# num2=int(input("Enter second number : "))
# print(num1+num2)
# except:
# print("please enter number only")
# print("hello pragati ")
# Use of finally keyword
def ErrorHandling():
try:
lst=['Pragati','Shubham','Karan','Rohit']
i=int(input("Enter index : "))
print(lst[i])
return 1
except Exception as e:
print(e)
return 0
finally:
print("hello pragati")
ErrorHandling()