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 trialBlessing Nyamayedenga
6,283 Pointshey guys , please I need help I seem not to get this right im getting an EOFError
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
20,315 PointsTo 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.
Blessing Nyamayedenga
6,283 PointsThanks Josh much appreciated
Blessing Nyamayedenga
6,283 PointsBlessing Nyamayedenga
6,283 Pointsim still getting this error
Blessing Nyamayedenga
6,283 PointsBlessing Nyamayedenga
6,283 PointsTraceback (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
20,315 PointsJosh Keenan
20,315 PointsEven with my code? You should have just those 4 lines and nothing more
Josh Keenan
20,315 PointsJosh Keenan
20,315 Pointsapologies 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
Josh Keenan
20,315 PointsJosh Keenan
20,315 PointsThat code passes now