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!
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
Jesus Martinez1,136 Points
Raising an Exception
What am I doing wrong? Please help!!!
def suggest(product_idea): product_idea = input("Enter product name. ") if len(product_idea) < 3: raise ValueError("Must be atleast 4 Charcters") return product_idea + "inator"
Robin Goyal4,582 Points
The product idea is actually passed into the function as an argument so you don't have to request input for it. Other than that, raising the exception is done correctly.
Mark RyanPython Web Development Techdegree Graduate 28,516 Points
Not sure what you're specifically getting stuck on, but I think I see a few issues. You may be getting a syntax error on line 2 (line 2 of your snippet here) - try adding 4 spaces before product_idea. It looks like you're attempting to catch a possible ValueError with your user's input - your code is missing an "except ValueError as err:" line under your if/raise block if you're trying to have more control over how the error is displayed to the user. Also, without seeing the rest of your code, it looks like passing product_idea into your function would be unnecessary - you're creating product_idea on line 2 of your snippet.
I'm new here as well, and this is my first answer in the community so I do hope I'm pointing you in the right direction!