+ 21
What should i do to print my own custom exceptions in python?
I have a simple code which raises an Exception "Invalid Name" But the output I'm getting is: Traceback (most recent call last): File "..\Playground\", line 2, in <module> raise NameError("Invalid name!") NameError: Invalid name! - - - - - - - - - - - - - - - - - - - - - - - - - - - - What should i do to get out like this only without that Traceback thing and file details: Expected output: NameError: Invalid name! - - - - - - - - - - - - - - - - - - - - - - - - - - - - You see in simple words i don't wanna Traceback (most recent call last): File "...... Is there any way? To do it? https://code.sololearn.com/chF9udu0WpsI/?ref=app
13 Réponses
+ 7
https://code.sololearn.com/c7s72VWhU4QS/?ref=app
0
Can u say eloborate
- 1
name = ("123")
print("NameError:"" Invalid name!") This Is
- 1
You need to put the output option un the middle of name and name error
- 1
try:
inp = int(input())
except:
print('Please enter integer value: ' ) # just printing this when exception occurs useful in most case
finally:
print('This prints no matter if exception occured or not.
There is raise:
# one to for raising exception.
- 3
Yep
- 3
Yep
- 3
Hello
- 3
Auuuuuu😊😊😊😊😊
- 5
Are you in contact