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![](https://ecs-static.teamtreehouse.com/assets/views/marketing/shared/community-banner-white-47072046c51352fe6a69f5e691ff5700b28bb11d45197d7bdf066d9ea3f72d0c.webp)
![Kanyon Dodson](https://secure.gravatar.com/avatar/a4491dfef7d60170abe562beb3c0590a?s=96&d=https%3A%2F%2Fecs-static.teamtreehouse.com%2Fassets%2Fcontent%2Fdefault_avatar-445fbbabfc8dc9188fb5967fe43322ee0c3e0dd1e10f378bf8343784af5a13eb.webp&r=pg)
Kanyon Dodson
453 Pointswhats wrong with my code
can someone help explain what im doing wrong
def suggest(product_idea):
return product_idea + "inator"
if product_idea <= 3:
raise ValueError("make your product idea more than 3 charactors")
2 Answers
![Steven Parker](https://uploads.teamtreehouse.com/production/profile-photos/969492/micro_tool_chess_set_2.jpg)
Steven Parker
230,688 PointsYou're close, but I see 3 issues:
- the new code must be done before the return
- it must also be indented to be part of the function
- the character requirement in the instructions is at least 3, not more than 3.
![Asher Orr](https://uploads.teamtreehouse.com/production/profile-photos/11686423/micro_updated_headshot_2022.jpg)
Asher Orr
Python Development Techdegree Graduate 9,408 PointsHi Kanyon- remember that the challenge is asking you to raise a ValueError if the string "product_length" is less than 3 characters.
In your code, you're first returning whatever is passed in as the product idea with "inator" added to it.
def suggest(product_idea):
return product_idea + "inator"
#in your code, you are first returning whatever is passed in as the argument (product_idea)..
#... then adding "inator" to that string.
When you click "Check Work", the Treehouse checker will run code like this:
suggest("repair")
Since the checker passed in "repair" as the argument, the code will return something like this:
repairinator
Before this happens, you want to raise a ValueError if the product_idea is less than 3 characters long. Your code should start with raising the ValueError IF the product_idea is less than 3 characters.
Let's get back to your code.
def suggest(product_idea):
if product_idea <= 3:
#you want to properly indent this, so Python knows it's part of the suggest function
#also, remember that product_idea is a string. Go back through your notes, and check what Craig said to do when you need to find the length of a string.
#lastly, notice that "<=" means "less than or equal to." It's supposed to be "less than" only.
raise ValueError("make your product idea more than 3 charactors")
Your code should start like this:
def suggest(product_idea):
#put your if statement here:
#then raise the ValueError
Once you've done that, add an "else" statement at the end. Like this:
def suggest(product_idea):
#put your if statement here:
#then raise the ValueError
#else:
#return the product_idea + "inator"
Does this answer your question? You have the right idea, you just need to re-arrange some of your code and make sure it's indented properly.