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 trialjames mchugh
6,234 PointsI'm trying to raise a value error, and it'a not working out
I think I'm not using the length properly. I keep getting this message. Bummer: Oh no, there were 2 problems with your code, check the preview pane for more information. The preview is saying something about object type int. I think it's how I'm declaring my len()
def suggest(product_idea):
if product_idea < len(3):
raise ValueError("Your product_idea needs to be more than 3 characters")
return product_idea + "inator"
1 Answer
Ari Misha
19,323 PointsHiya there! You're right about "len()" method though but if you check the docs, you'll find that len() method takes in an array, not int but it throws an Int. So yeah your answer should look like this:
def suggest(product_idea):
if len(product_idea) < 3:
raise ValueError("Your product_idea needs to be more than 3 characters")
return product_idea + "inator"
I hope it helped!
~ Ari
james mchugh
6,234 Pointsjames mchugh
6,234 PointsThanks Ari. I knew I was close. Thanks for suggesting to look at the documentation. Next time I will
Ari Misha
19,323 PointsAri Misha
19,323 Pointsjames mchugh A simple super helpful tip: Download docs for whatever IDE you're using and you can get documentation right in your IDE. I'd highly recommend PyCharm 'coz it'll help you a lot, plus its a go-to IDE for Python in Startups to Enterprises. Press ctrl+Q on any method and you'll get docs right in your IDE. It's that simple and informative (: