Exception | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 2

Exception

try: num=5/int(input()) print(num) except: print("an error occur") raise I put a as input ....and it raise ValueError.....pls why did it raise ValueError and not TypeError

6th Sep 2022, 7:53 PM
Oyedeji Hiqmat
Oyedeji Hiqmat - avatar
2 Answers
+ 1
an error occur Traceback (most recent call last): File "file0.py", line 2, in <module> num=5/(input()) TypeError: unsupported operand type(s) for /: 'int' and 'str' if you want a TypeError delete int so divide int / str
6th Sep 2022, 8:10 PM
**🇦🇪|🇦🇪**
**🇦🇪|🇦🇪** - avatar
+ 1
Prince Kumar in wht kind of example would that second example be type error
7th Sep 2022, 7:06 AM
Oyedeji Hiqmat
Oyedeji Hiqmat - avatar