Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialCedrick Cyizere
275 PointsI am getting an exception not raised error and an EOF error i don't know what seems to be the problem .
def suggest(product_idea):
if len(product_idea) <= 3:
raise ValueError("the value is less than 3 characters")
return product_idea + "inator"
try:
suggest( product_idea=(input("please choose a product ")))
except ValueError as err:
print("the value is less than 3 characters")
else :
print (product_idea)
2 Answers
Joseph Yhu
PHP Development Techdegree Graduate 48,638 PointsYou don't need any of that extra stuff; all you need is this part:
if len(product_idea) <= 3:
raise ValueError("the value is less than 3 characters")
Actually, the extra stuff might be why you are getting errors.
Luke Davis
1,394 PointsI've seen the answer now just want to know why this doesn't work i can run it and it does what the task asks and runs fine just keep getting Traceback (most recent call last): File "", line 30, in test_exception_raised File "/workdir/utils/challenge.py", line 24, in execute_source exec(src) File "", line 6, in ValueError: the product has to be longer than 3 characters
Any chance you can elaborate
def suggest(product_idea): return product_idea + "inator" product_idea = "a"
if len(product_idea) < 3: raise ValueError("the product has to be longer than 3 characters")
else: print(product_idea)
Joseph Yhu
PHP Development Techdegree Graduate 48,638 PointsAgain, you don't need the else clause; you only need:
if len(product_idea) < 3:
raise ValueError("the product has to be longer than 3 characters")
And you should put it before the return.