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 trialrsa14
1,865 PointsI put the raise function in but it says I didn't raise? Also it says indentation is wrong but I'm just like the video?
Am I missing something in the raise function? How does it differ when you're dealing with a string as opposed to an integer? And it says my indentation is wrong even though mine looks to me like the lesson video, do you know what's wrong with it? Are there any quick go-to rules for indentation? Thanks! :) Sorry for the questions! :)
def suggest(product_idea):
return product_idea + "inator"
if product_idea = < 3:
raise ValueError ("Product Idea Must be three or more letters long")
2 Answers
Istvan Nonn
2,092 PointsHi Avi Rajender, Your solution is almost perfect, you just need two minor changes. First of all I will highly recommend to place your "return" at the end of the function.
Function bodies can contain one or more return statement. They can be situated anywhere in the function body. A return statement ends the execution of the function call and "returns" the result, i.e. the value of the expression following the return keyword, to the caller. If the return statement is without an expression, the special value None is returned. If there is no return statement in the function code, the function ends, when the control flow reaches the end of the function body and the value "None" will be returned.
def suggest(product_idea):
# your code here - in this case the if statement
return product_idea + "inator"
Also, pay attention to the "if statement" - Conditional Expressions and use the len() method that will return the length of your data type.
if len(string) <= 3:
The last thing, I am not sure exactly how code checker works, but even just a blank space can make an error:
# your code
raise ValueError ("Some message here")
# accepted code
raise ValueError("Some message here")
Sarat Chandra
4,898 PointsCouple of things:
return should be at the end of the function.
'product_idea' is a string here. You need to know the length of the characters. Hint: len()
There should not be spaces between operands. In your code, < and = should not be separated by spaces.
Good luck!
rsa14
1,865 PointsThank you so much! Makes sense that there shouldn't be a space.
rsa14
1,865 Pointsrsa14
1,865 PointsOh I didn't even consider the len() method - got it. Thank you so much!