0
Can't pass internal test
Hello dear friends, this task is easily, but I can not find mistake. Below text of task and my code: Text of task: 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 My code: try: name = input() #ĐČĐ°Ń ĐșĐŸĐŽ if len(name) < 4: raise ValueError except: print("Invalid Name") else: print("Account created")
6 Answers
+ 9
But in this challenge, you just have to raise an error message. It can be ValueError or NameError.
Here, c should be changed to uppercase in "Created".
+ 6
print("Account Created)
+ 1
NameError
+ 1
Thanks! How important is it to use the correct name of the exception in this case, or is it necessary only to pass the internal test?
+ 1
Refer to these sites or can also learn it from the Python course:
https://www.journaldev.com/33500/python-valueerror-exception-handling-examples
http://ubanalytics.com/programming/difference-between-typeerror-and-valueerror/
https://stackoverflow.com/questions/48343387/valueerror-and-typeerror-in-python
+ 1
Many thanks!