Python Python Basics Functions and Looping Raise an Exception

Catherine Paris
Catherine Paris
1,504 Points

How do you coerce an int into a string?

I need to keep the user from entering less than 3 characters

I tried <char(3) but didn't work

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

1 Answer

KRIS NIKOLAISEN
PRO
KRIS NIKOLAISEN
Pro Student 47,519 Points

You need to find the number of characters in product_idea and compare that to the number 3. For this you can use the len() method as shown here.