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

Gabriella Villareal
Gabriella Villareal
229 Points

There are a bunch of random errors that pop up and I have no idea what an indentation error is.

Also, if anything else in my code is off, please tell me.

def suggest(product_idea):
    return product_idea + "inator"
 understand = input("put a name idea here  ")
if understand != len(stringToCheck):
    if product_idea  <= 3:
        raise ValueError("please put a longer name  ")

1 Answer

Steven Parker
Steven Parker
229,921 Points

Indentation is a common way to indicate program structure and flow. In other languages, this is typically a "best practice" but technically optional; but in Python it is mandatory.

Indentation per level should be consistent throughout the program. In the starter code provided, you can see that the indentation used is 4 spaces. So every line of code added should be indented by some multiple of 4 spaces (or none).

A few additional hints:

  • the instructions ask for code to be added to the function, which means it must come before the return
  • anything inside the function will also be indented
  • the instructions do not ask for anything to be input, just work with the parameter
  • you'll want to test the length of the idea, not the numeric value of the idea
  • the error should occur when the length "is less than 3 characters", so 3 would be OK