Someone plz help me out... Tried to solve it... But didn't get the output. | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

Someone plz help me out... Tried to solve it... But didn't get the output.

You are making a registration form for a website. The form has a name field, which should be more than 3 characters long. Any name that has less than 4 characters is invalid. Complete the code to take the name as input, and raise an exception if the name is invalid, outputting "Invalid Name". Output "Account Created" if the name is valid. Sample Input: abc Sample Output: Invalid Name

19th Feb 2021, 9:34 AM
Niviedha shekor
Niviedha shekor - avatar
23 Answers
+ 8
try: name = input() if len(name)<4: raise NameError except: print("Invalid Name") else: print("Account Created")
13th May 2021, 6:41 AM
Davor Budimir
Davor Budimir - avatar
+ 2
try this code i think this might help try: name = input() #your code goes here if len(name) < 4: raise Error else: print("Account Created") except: print("Invalid Name")
23rd May 2021, 2:52 PM
Abhishek Biswas
Abhishek Biswas - avatar
+ 1
Sandeep Kushwaha Thank you so much for your answer.
20th Feb 2021, 9:30 AM
Niviedha shekor
Niviedha shekor - avatar
+ 1
Use this code, I think this is simple code try: name = input() if len(name) > 3: print ("Account Created") else: raise NameError except: print("Invalid Name")
2nd Jul 2021, 8:47 AM
Hossein Eshraghi
Hossein Eshraghi - avatar
+ 1
try: name = input() #your code goes here if len(name)<4: raise NameError except: print("Invalid Name") else: print("Account Created")
15th Aug 2021, 6:34 PM
Vraj Soni
Vraj Soni - avatar
+ 1
name = input() if (len(name) < 4): print("Invalid Name") else: print("Account Created") Thank me later... surprisingly this works
3rd Oct 2021, 4:01 PM
Harsh Bundela
Harsh Bundela - avatar
0
Niviedha shekor Show your attempt
19th Feb 2021, 10:29 AM
R💠🇮🇳
R💠🇮🇳 - avatar
0
try: name = input() #your code goes here if name==(str(len >=4)): raise("Account Created") except: print("Invalid Name")
19th Feb 2021, 10:30 AM
Niviedha shekor
Niviedha shekor - avatar
0
Posted my attempt above
19th Feb 2021, 10:31 AM
Niviedha shekor
Niviedha shekor - avatar
0
Niviedha shekor Invalid syntax error
19th Feb 2021, 10:44 AM
R💠🇮🇳
R💠🇮🇳 - avatar
0
Have also tried this coding name = input() try: name == (str(len <= 3)) raiseexception("InvalidName") except: print("Account Created")
19th Feb 2021, 11:05 AM
Niviedha shekor
Niviedha shekor - avatar
19th Feb 2021, 11:18 AM
R💠🇮🇳
R💠🇮🇳 - avatar
0
you are comparing name with stringified boolean, while you are supposed to compare name.length to boundary (3-4), plus you don't need try/except: name = input() if len(name) < 4: raise Exception('Invalid Name') else: print('Axcount Created')
19th Feb 2021, 12:39 PM
visph
visph - avatar
0
try: name = input() #your code goes here if len(name)<4: raise NameError except: print("Invalid Name") else: print("Account Created")
20th Aug 2021, 6:43 PM
Ronny Karani
Ronny Karani - avatar
0
try: name = input() #your code goes here if len(name)<4: raise NameError except: print("Invalid Name") else: print("Account Created")
1st Oct 2021, 4:08 PM
Hariom Kumar
Hariom Kumar - avatar
0
try: name = input() #your code goes here if len(name) < 4: raise Error #raise statement else: print("Account Created") except: #except statement print("Invalid Name")
13th Oct 2021, 5:01 AM
Pratap Vasava
Pratap Vasava - avatar
0
try: name = input() #your code goes here if len(name)<4: raise NameError except: print("Invalid Name") else: print("Account Created")
9th Dec 2021, 4:43 PM
Mirmahmud Ilyosov
Mirmahmud Ilyosov - avatar
0
try: name = input() #your code goes here if len(name)<4: raise NameError except: print("Invalid Name") else: print("Account Created")
16th Dec 2021, 6:22 AM
Marvin Manaog
Marvin Manaog - avatar
0
try: name = input() #your code goes here if len(name)<4: raise NameError except: print("Invalid Name") else: print("Account Created")
17th Dec 2021, 10:21 AM
Ismoilov Abdug'ofur
Ismoilov Abdug'ofur - avatar
0
try: name = input() if len(name)<4: raise NameError except: print("Invalid Name") else: print("Account Created")
23rd Dec 2021, 2:24 AM
Md. Rakibul Islam
Md. Rakibul Islam - avatar