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

Joel Rapp
Joel Rapp
862 Points

Raising an exception code challenge

i keep getting syntax errors and indentation errors when i write "Check Work". I'm not quite sure if im writing the code wrong (most likely) but i thought i followed each step correctly.

suggestinator.py
def suggest(product_idea):
    return product_idea + "inator"

1 Answer

Tim Rach
seal-mask
.a{fill-rule:evenodd;}techdegree
Tim Rach
Full Stack JavaScript Techdegree Student 25,127 Points

Should do the job

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

Thank You! This really helped!

had a feeling i needed to use len... i was going off the logic that was shown off of the previous videos before this test. was trying to write up code for the user to input something into the code and have it check to see what the product was and if it was to long... but no. lol. its literally as simple as using len in the fuction... wont be forgetting "len" any time soon... but just to blow off steam... IT WANST USED AT ALL IN THE VIDEOS WITH THIS TEST. Feel better now waisting so much time trying to code that up. at least i get it.