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 trial

Python Python Basics Functions and Looping Raise an Exception

After practicing the try,except , and raise. I still can't solve this challenge

What am I doing wrong

suggestinator.py
def suggest(product_idea):
    char_count = len(product_idea)
    if char_count <=3:
        raise ValueError ("Less Than 3")
    return product_idea + "inator"
try:
    idea = input ("Enter Product Idea ")
    idea = suggest (idea)
    print (idea)
except ValueError as err:
    print ("Not Correct")
    print ("{}".format(err))

1 Answer

Hi, I think your overcomplicated the problem. Let us break it down. The only thing we are asking is that if the length of the product is smaller than 3, we need to raise a Value Error This could be done by doing : def suggest(product_idea): #if the length of product is smaller than 3 ,raise an exception if len(product_idea) < 3: raise(ValueError) return product_idea + "inator"

Thank You Victor. Looks Like I understood the problem and I was just reading to deep into it. I solved it now.