+ 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

25th Sep 2019, 7:28 AM
Aakaanksha 💕 [TheBraveCoders]
Aakaanksha 💕 [TheBraveCoders] - avatar
13 Answers
+ 7
https://code.sololearn.com/c7s72VWhU4QS/?ref=app
25th Sep 2019, 10:25 AM
Gordon
Gordon - avatar
+ 8
Sofia, FERZ please don't spam here 🙄 - - - - - - - - - - - - - - - - - - - - - - - Gordon That answer was really so much helpful thank you buddy 👍😆
26th Sep 2019, 11:11 AM
Aakaanksha 💕 [TheBraveCoders]
Aakaanksha 💕 [TheBraveCoders] - avatar
0
Can u say eloborate
26th Sep 2019, 5:32 PM
5 star clicks
5 star clicks - avatar
- 1
name = ("123") print("NameError:"" Invalid name!") This Is
26th Sep 2019, 5:24 PM
MineLa Playz
MineLa Playz - avatar
- 1
You need to put the output option un the middle of name and name error
27th Sep 2019, 4:23 AM
Victor Adrian Morales Diaz
Victor Adrian Morales Diaz - avatar
- 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.
27th Sep 2019, 7:56 AM
★«D.Connect_Zone»
★«D.Connect_Zone» - avatar
- 3
Yep
25th Sep 2019, 11:15 PM
Sofia
- 3
Yep
25th Sep 2019, 11:15 PM
Sofia
- 3
Hello
26th Sep 2019, 10:24 AM
FERZ
- 3
Auuuuuu😊😊😊😊😊
26th Sep 2019, 10:25 AM
FERZ
- 5
Are you in contact
26th Sep 2019, 11:42 AM
FERZ