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 trialAlex Rodriguez
929 PointsI dont know what to do, I'm stuck
I keep getting other exceptions and I'm unsure what to do
def suggest(product_idea):
if len(product_idea) < 3:
raise ValueError("Please type in something 3 characters or more.")
return product_idea + "inator"
try:
suggestion = input("What product idea were you thinking of? ")
newName = suggest(suggestion)
print("This should be your product idea name, {}".format(newName))
except ValueError as err:
print("{}".format(err))
1 Answer
Viraj Deshaval
4,874 PointsJust indent your try and except block, it should run within the function. Your code should like as shown below:
def suggest(product_idea):
if len(product_idea) < 3:
raise ValueError("Please type in something 3 characters or more.")
return product_idea + "inator"
try:
suggestion = input("What product idea were you thinking of? ")
newName = suggest(suggestion)
print("This should be your product idea name, {}".format(newName))
except ValueError as err:
print("{}".format(err))
Alex Rodriguez
929 PointsAlex Rodriguez
929 PointsThanks Viraj, I was overthinking it. I only needed to use like 4 lines of code, but yeah the indentation was my initial screw up too.