Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

Python Python Basics Functions and Looping Raise an Exception

I can't figure out how to fix my error handling code.

I can't figure out how to fix my error handling code. I think I know what the problem is, but I've no idea how to fix it

suggestinator.py
def suggest(product_idea):
    if product_idea < 3:
        raise ValueError("You must use 3 or more characters.")
    return product_idea + "inator"

    except ValueError as err:

How can this be a value error when the text is a string? I guess I can count the number of letters, but I don't know how to do that. Did we do that? and I don't know what the "inator" is, so I was afraid to remove it.

3 Answers

Mark Sebeck
MOD
Mark Sebeck
Treehouse Moderator 33,558 Points

Hi Rina. I have a confession. I didn't remember how to determine the length of a string in Python either. So I googled it and found this

# Length of below string is 5
string = "geeks" 
print(len(string))

so i think you just need to call len(product_idea) in your if statement and it should work.

Keep at it and don't be afraid to google something you don't know. Everyone does.

Mark Sebeck
MOD
Mark Sebeck
Treehouse Moderator 33,558 Points

Also delete your last line

except ValueError as err:

That line is not needed

Thank you! I will try this!

It worked! Thank you!