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 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 38,004 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 38,004 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!