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 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 5,531 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"

boi
boi
14,242 Points

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"