Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

Python Python Basics All Together Now The Project

Kelly Pellas
Kelly Pellas
681 Points

My code for the suggestion task works in my editor but not the one in the course. I'm not sure what to do?

Here's the code that works:

def suggest(product_idea): return product_idea + "inator"

product_idea = input("What is your product idea? ") try: if len(product_idea) <= 3: raise ValueError("The name is too short!") except ValueError as err: print("Oh no, {} Please try again.".format(err)) else:
suggestion = suggest(product_idea) print(suggestion)

3 Answers

Maciek Radomski
seal-mask
.a{fill-rule:evenodd;}techdegree
Maciek Radomski
Python Development Techdegree Student 2,273 Points

they ask you to "Can you please raise a ValueError if the product_idea is less than 3 characters long? product_idea is a string. Thanks in advance!" so this is the only thing you have to do for this task:

def suggest(product_idea): if len(product_idea) < 3: raise ValueError("The name is too short! Please try again.") return product_idea + "inator"

Before I try to help, can you confirm

def suggest(product_idea): 
    return product_idea + "inator"

product_idea = input("What is your product idea? ") 
try: 
    if len(product_idea) <= 3: 
        raise ValueError("The name is too short!") 
except ValueError as err:

    print("Oh no, {} Please try again.".format(err))

    else:
        suggestion = suggest(product_idea) 
print(suggestion)

ā˜ Is this how your code should look?

This is a simple option that I used, and it worked just fine.

def suggest(product_idea): if len(product_idea) < 3: raise ValueError("{} is too short, try again.".format(product_idea)) return product_idea + "inator"