Exception handling in python
# a = 5
# b=0
# try:
# print(a/b)
# except Exception:
# print("hey, you can't divide a number by zero")
#
# print("last output")
# a = 5
# b=0
# try:
# print(a/b)
# except Exception as e:
# print("hey, you can't divide a number by zero",e)
#
# print("last output")
a = 5
b=2
try:
print("resource open")
print(a/b)
k = int(input("Entr number :"))
print(k)
except Exception as e:
print("Something, went worng...",e)
finally:
print("resource close")
print("last output")
resource open 2.5 Entr number :p Something, went worng... invalid literal for int() with base 10: 'p' resource close last output
Post a Comment