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 trialRaul Lomelino
374 PointsWhere am I going wrong?
def suggest(product_idea):
if product_idea >= str(3):
raise ValueError("Product idea needs 3 or more characters")
else:
return product_idea + "inator"
2 Answers
Asher Orr
Python Development Techdegree Graduate 9,410 PointsHi Raul!
The problem is this line of code:
if product_idea >= str(3):
The challenge asks to raise a ValueError if product_idea (a string) is less than 3 characters long.
To find out how many characters are in a string, use the len function. Here's an example:
name = "Asher"
return len(name)
If I ran this code, it would return 5- since there are 5 letters/characters in my name.
Back to your code:
if product_idea >= str(3):
#try an if statement that says "if the length of product_idea is less than 3"
Also, you should remove the equals (=) operand. Let me explain why:
name = "Raul"
if len(name) >= 4:
Raise ValueError
#this says if the length of name is greater than or equal to 4, raise a ValueError.
name = "Raul"
if len(name) > 4:
Raise ValueError
#this says if the length of name is greater than 4, raise a ValueError.
I hope this helps. Let me know if you need more help!
Raul Lomelino
374 PointsIt worked like a charm, thank you!