Python Python Basics Functions and Looping Raise an Exception

Deonte Meriwether
Deonte Meriwether
1,513 Points

value error format

Im having trouble raising value errors and creating the condition when I need to calculate the number of characters inpu

suggestinator.py
def suggest(product_idea):
   if len(product_idea) < 3 raise ValueError("Too short try again")

    return product_idea + "inator"

1 Answer

Daniel Turato
PRO
Daniel Turato
Java Web Development Techdegree Graduate 30,108 Points

Raising the error should be on it's own separate line like so:

def suggest(product_idea):
   if len(product_idea) < 3:
       raise ValueError("Too short try again")

    return product_idea + "inator"
Deonte Meriwether
Deonte Meriwether
1,513 Points

Oh I see now. Thank you for helping me with this one Daniel! It seems like I was so close but still so far from solving this one :)