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 trialKennedy Malonga
22,856 PointsCan you please raise a ValueError if the product_idea is less than 3 characters long? product_idea is a string. Thanks i
where should i test the length of the string instead of the string itself will int() be needed anywhere
def suggest(product_idea):
if product_idea < 3:
raise ValueError("characters too short")
return product_idea + "inator"
4 Answers
Kennedy Malonga
22,856 Pointsfinally got it right by mistake
def suggest(product_idea): if len(product_idea) < 3: raise ValueError("characters too short") return product_idea + "inator"
Lindsey Mote
Data Analysis Techdegree Student 1,148 PointsI'm stuck on this one as well! I used the same code as suggested by Kennedy above and got the following error: AssertionError: None != 'baconinator' : I passed in 'bacon' and expected 'baconinator', but got 'None'
Steven Parker
231,248 PointsTry creating a fresh question where your exact code will be shown.
Johnathan Lopez
597 PointsDid we ever figure this out? I just got stuck here as well.
Steven Parker
231,248 PointsYea, Kennedy realized he was testing the string itself instead of the length of the string. He just forgot to use Markdown formatting on the code in his answer.
Steven Parker
231,248 PointsYou won't need int()
, but you might need to use the len()
function.
Kennedy Malonga
22,856 Pointsill just skip i give up
tristan traphagan
1,824 PointsI'm running into an issue where I keep getting an EOF error on line 5 which is my input line and I'm assuming it has something to do with product_idea being a string can someone please hint me towards what is wrong with it?
def suggest(product_idea): return product_idea + "inator"
product_idea = input("whats your product idea? ")
if len(product_idea) < 3: raise ValueError("please 3 characters or more")
tristan traphagan
1,824 Pointsnevermind i r just got it i was doing too much
Steven Parker
231,248 PointsSteven Parker
231,248 PointsNo "mistake" there – you got it!