-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtry_except.py
More file actions
45 lines (35 loc) · 808 Bytes
/
try_except.py
File metadata and controls
45 lines (35 loc) · 808 Bytes
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
'''while True:
try:
p=int(input("please enter an integer:"))
break
except:
print("not a valid input, please try again!")
try:
5/0
except ZeroDivisionError:
print ("please dont divide by 0")
r=100
try:
print("money"+r+"Available")
except TypeError:
print("i told you this gives a Type Error")
# multiple exception handler
r=100
try:
print("money"+r+"Available")
5/0
except ZeroDivisionError:
print ("please dont divide by 0")
except TypeError:
print("i told you this gives a Type Error")
else:
print("this is else block if try succeeds it will be executed")
finally:
print("Thanks for attempting this session")'''
# multiple exception chaining
r=100
try:
print("money"+r+"Available")
5/0
except TypeError:
print("money"+r+"Available")