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

Jason Loveless
Jason Loveless
726 Points

Trying to complete this challenge but I am struggling pls help

Can you please raise a ValueError if the product_idea is less than 3 characters long? product_idea is a string.

suggestinator.py
def suggest(product_idea):
    product_idea = input("What is your idea?")
    if int(product_idea) <= 3:
        raise ValueError("Too few characters")
    return product_idea + "inator"

2 Answers

Steven Parker
Steven Parker
231,248 Points

The product idea is provided as an argument, you won't need to "input" anything.

Also, you want to test the length of the argument instead of trying to convert it directly into a number.

Jason Loveless
Jason Loveless
726 Points

really confused, please could you send me some example code

Steven Parker
Steven Parker
231,248 Points

You nearly have it, just:

  • delete the line that has "input" on it
  • change "int(product_idea)" to "len(product_idea)"