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

Ramsley Brice
Ramsley Brice
4,767 Points

Hello I keep getting File "", line 7, in EOFError: EOF when reading a line, but the console reads my code correctly

Hello,

I tried to complete the challenge but I keep receiving an error. And I don't know why. It seems to be due to my input line 7. Would someone know why? Thanks!

suggestinator.py
def suggest(product_idea):
    if len(product_idea) < 3: #test the exception
        raise ValueError("This idea is too short!")
    return product_idea + "inator"

try:
    product_idea = input("What is your suggestion?")
    idea_name = suggest(product_idea)
except ValueError as err:
    print("Oh no! That's not a valid value. Try again...")
    print("({})".format(err))
else:
    print("Your new brand product name is {}!".format(idea_name))

5 Answers

Jordan DeLeon
Jordan DeLeon
1,074 Points

Your code is correct, however, the try statement should be included in the above function.

You are missing the end keyword after your return statement.

Ramsley Brice
Ramsley Brice
4,767 Points

By end keyword, what do you mean? I seem to have skipped this detail.

Never mind that. Got my languages confused. I would check your try/catch.

Miguel Soriano
seal-mask
.a{fill-rule:evenodd;}techdegree
Miguel Soriano
Front End Web Development Techdegree Student 3,895 Points

Hi Ramsley you only need the first 4 lines, you don't need the rest for the challenge. You're coding is already correct maybe just add "<=" in if len(product_idea) <= 3:

def suggest(product_idea): if len(product_idea) <= 3: raise ValueError("the idea is too short") return product_idea + "inator"

Ramsley Brice
Ramsley Brice
4,767 Points

Great Thanks Miguel!! It worked when I only kept the function!