+ 1
Can assign variable to error type in python ?
so in future i can use that variable in tha place of the error type like i had tried in balow code but is showing error. try: ZeroDivisionError=zero print("Hello") print(1 / 0) except Zero: print("Divided by zero") finally: print(10/1)
3 ответов
+ 5
Yeah that's possible but you have to assign the other way around:
zero = ZeroDivisionError
now it will work
+ 2
Yep you can all of these are objects so you can store them,
fixed your code here
https://code.sololearn.com/chzFNaNCi4PQ/?ref=app