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

i cant answer this question

can i get the asnswer for this question

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

2 Answers

Jason Anders
MOD
Jason Anders
Treehouse Moderator 145,858 Points

Hi Filmon,

The Community is not a place where answers are just given out. It is a place to come for help and hints.

With that in mind, you are on the right track. There are just a few things not quite right with some syntax and naming.

  • First, the if statement is missing the colon need to open it's block.
  • Python is case sensitive, so valueError is not the same as ValueError... you need ValueError
  • Also, Python is very indent specific. Right now, the return statement is inside the if statement. It needs to be outside that, but still inside the function.

I'm sure you can get it now. :)

Nice work so far! :dizzy:

thank you i like your put it.

Ben Hedgepeth
seal-mask
.a{fill-rule:evenodd;}techdegree
Ben Hedgepeth
Python Web Development Techdegree Student 10,287 Points

You have syntax and name errors and indentation issues with your code.

You need a : on your conditional statement. For any error you want to except/raise, it must be title-cased and must have () at the end. Think of it as if you're calling an error on purpose.

Try to figure out how the block is supposed to be structured in the context of a True/False situation.

Jason Anders
Jason Anders
Treehouse Moderator 145,858 Points

Hi Ben Hedgepeth ,

Actually ValueError without any parentheses is correct syntax. It's a Python Exception and does not take () after the name. You can have a look at the Errors and Exceptions Docs for some examples. Or these Raise Exception Examples.

:dizzy: