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 trialDana Sayer
281 PointsCan someone please help? I have no idea what to do here.
Can someone please help? I have no idea what to do here.
def suggest(product_idea):
return product_idea + "inator"
raise ValueError if: product_idea is les
1 Answer
Alex Koumparos
Python Development Techdegree Student 36,887 PointsHi Dana,
Your first problem is that your raise ValueError if: product_idea is les
will never be executed. The previous line is a return statement and any line that is executed that return
s will always end execution of the function.
This means you need to test whether product_idea
is less than 3 characters long before you get to the return
line.
It looks like you might still be confused with the syntax for if
, so consider rewatching If, Else and Elif. Or look at the official Python docs for if statements. In short, you need to start with if
then your condition, then the :
character.
Once inside the if
branch you need to write the code that should execute if your condition is met, so assuming your condition tests whether product_idea
is less than 3 characters long, the code inside the branch will do whatever you want to happen for situations where the product_idea
is less than 3 characters long. This is where you would raise your ValueError
.
It also looks like you're unclear about how to check the length of a string. Here you want to use the len()
function (not "les" which is what you have).
Once you know the length of the string, you can compare it to the value 3. You can find an explanation of Python's comparison operators in the official docs. You will want to use the "less than" operator, which is the <
symbol.
Hope that clears everything up for you.
Cheers
Alex