Exception Handling
## try, except , else and finally
try:
x=10/0
except ZeroDivisionError:
print("10/0 is impossible")
else:
print("no error")
## other example
try:
a=6
a.lower()
except AttributeError:
print("int value doesnt have lower() method")
else:
print("no error")
"C:\Users\darul Haram\PycharmProjects\pythonProject2\venv\Scripts\python.exe" "C:/Users/darul Haram/PycharmProjects/pythonProject2/venv/Lib/Exception Handling.py" 10/0 is impossible int value doesnt have lower() method Process finished with exit code 0
Comments
Post a Comment