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

hey guys , please I need help I seem not to get this right im getting an EOFError

suggestinator.py
def suggest(product_idea):
    return product_idea + "inator"
    if len.product_idea < 3:
        raise ValueError ("please enter longer name ")
try:
    input("please enter your suggestion")
except ValueError as err :
    print("{}" .format(err))
else:
    print(product_idea)

suggest()

2 Answers

Josh Keenan
Josh Keenan
19,652 Points

To complete the challenge this is all you need:

def suggest(product_idea):
    if len(product_idea) < 3:
        raise ValueError
    return product_idea + "inator"

Firstly, you need to check if it is valid before you return the new string, you don't need to output anything if the product idea is less than 3 characters, only raise the exception.

im still getting this error

Traceback (most recent call last): File "", line 32, in test_exception_raised File "", line 2, in suggest AttributeError: 'builtin_function_or_method' object has no attribute 'product_idea'

Josh Keenan
Josh Keenan
19,652 Points

Even with my code? You should have just those 4 lines and nothing more

Josh Keenan
Josh Keenan
19,652 Points

apologies I misread your code, you used the len function incorrectly, it is called by using parentheses at the end, not a dot.

len(my_string)

This will get the length of the variable my_string

Thanks Josh much appreciated