in the last line when i
was printed the message by using alias it was running fine .for example
except insufficient as i :
print("exception is caught",i.msg)
but when I did this
except insufficient :
print("exception is caught",insufficient.msg)
it was an error ..why???
```class insufficient(ZeroDivisionError):
def __init__(self,arg):
self.msg=arg
balance=5000
w=int(input("enter a number"))
try:
if w>5000:
raise insufficient("balance in the account is insufficient")
balance=balance-w
print("no exception and balance is=",balance)
except insufficient :
print("exception is caught",insufficient.msg)```
Error Log:-
Traceback (most recent call last):
File "C:\Users\ahmod\AppData\Local\Programs\Python\Python37-32\hello.py", line 8, in <module>
raise insufficient("balance in the account is insufficient")
insufficient: balance in the account is insufficient
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Users\ahmod\AppData\Local\Programs\Python\Python37-32\hello.py", line 12, in <module>
print("exception is caught",insufficient.msg)
AttributeError: type object 'insufficient' has no attribute 'msg'