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

Python Python Basics Functions and Looping Raise an Exception

l 've madan exception can you please a ValueErrorif the product_idea is less than 3 characters long? thanks in advance.

l 've made a function that creates brand new products names using artificial interlligence. l have a problem though,people keep on adding product ideas that are too short it makes the suggetion looks bad. can you please raise a ValueError if the product_idea is less than 3 characters long?thanks in advance.

nakalkucing
nakalkucing
12,964 Points

Hi Masline Nyasha Petro! I'd love to help. But what exactly is your question? If you could explain your question and include your problem piece of code it would be much appreciated. Best, Nakal :)

1 Answer

def suggest(product_idea):
    if len(product_idea) < 3:
        raise ValuError
    return product_idea + "inator"

If the length of the string passed to the func is less than 3, raise the error. The func won't return a value unless the string is the desired length.

nakalkucing
nakalkucing
12,964 Points

Hi adam n! Just so you know, It is frowned on to simply give someone the finished code. :) Good luck! Hope this helps, Nakal

nakalkucing does my code pass the challenge?