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

Alex Fredette
Alex Fredette
7,340 Points

suggestinator

I am not sure what I'm doing wrong. The only thing that doesn't feel right is the application of len

suggestinator.py
def suggest(product_idea):
    if len(product_idea) <3:
        raise ValueError("Oh no! It's too short!")
    return product_idea + "inator"

suggest("co")

1 Answer

Rachel Johnson
STAFF
Rachel Johnson
Treehouse Teacher

Hey Alex Fredette ! Thanks for sharing your question to the forum.

You're actually 100% in your implementation of the function! The following is perfect

def suggest(product_idea):
    if len(product_idea) <3:
        raise ValueError("Oh no! It's too short!")
    return product_idea + "inator"

What's throwing off the code challenge is the line of code calling suggest() the function. It's actually running the function with "co" the string and is therefore producing some unexpected outputs that the code challenge isn't expecting.

If you change your code challenge to just include the function and remove the call to suggest() then you'll pass with no issues!