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 trialSanamdeep Singh
Python Web Development Techdegree Student 1,741 PointsCan't figure out this question, can someone help ?
I've made a function that creates brand new product names using artificial intelligence. I have a problem though, people keep on adding product ideas that are too short. It makes the suggestions look bad. Can you please raise a ValueError if the product_idea is less than 3 characters long? Thanks in advance!
def suggest(product_idea):
if product_idea <= 3:
raise ValueError("Need a longer idea.")
return product_idea + "inator"
10 Answers
Sanamdeep Singh
Python Web Development Techdegree Student 1,741 PointsThanks guys, I got this and it worked.
def suggest(product_idea):
if len(product_idea) < 3:
raise ValueError("Please try again.")
return product_idea + "inator"
Chad Sutton
2,483 Pointsrecall the len() concept to return how many characters in a string. Almost there!
r j weiner
2,741 Pointssuch a simple explanation so helpful thanx
Sanamdeep Singh
Python Web Development Techdegree Student 1,741 PointsWe suppose to use len function right ?
Craig Dennis
Treehouse TeacherYeah, what does your current code look like Sanamdeep?
Craig Dennis
Treehouse Teacherproduct_idea
is a string. How do you determine the number of characters in a string?
Let me know if that hint doesn't do it for you ;)
Sanamdeep Singh
Python Web Development Techdegree Student 1,741 PointsI tried working with len but I still can't get the right answer
Antonio De Rose
20,885 PointsSanamdeep Singh did you get it right, if not could you send the code, you have tried so far
Ayrton Haider
2,439 PointsI struggled with this one for a bit but I finally figured it out....
def suggest(product_idea):
if len(product_idea) <= 3:
raise ValueError("You need a longer idea!")
return product_idea +"inator"
Does anyone else struggle to remember all of this stuff? Tips? Do people take notes?
Jelena Simic
285 PointsYes, omg I struggle too. But every time I look at it, it gets a microscopic amount easier and I see hope. No, I haven't been taking notes, but I'm going to start.
Mallik V
721 Pointsdef suggest(product_idea): if len(product_idea) <= 3: raise ValueError("Product idea should be longer. ") return product_idea +"inator"
Tebogo Sosome
738 Pointsi really struggled here
Kristina Rodriguez
Web Development Techdegree Student 1,830 PointsI really struggled with this one until I found this discussion. I don't think I'm understanding creating variables and I watched that video a couple of times too. This is not as easy as I taught or is it just me? ( ′~‵ )
Edwin Castro
Courses Plus Student 24,037 PointsOH MY GOD!!! I had it as
product_idea.len()
I'm such a bone head!!!