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 trialIgor Ozherelyev
2,052 Pointscan't see what's wrong with my code. It showing exceptions all the time
Does it work well?
def suggest(product_idea):
If len(product_idea) < 3:
raise ValueError("is less than 3 characters long?")
return product_idea + "inator"
2 Answers
Steven Parker
231,275 PointsPython is case-sensitive. You wrote "If" (capital "I"), but it should be "if" (lower-case).
Igor Ozherelyev
2,052 PointsYeah, that was the reason. I used the tab instead of spaces in one file. Thanks so much for your help! 🙌
Igor Ozherelyev
2,052 PointsIgor Ozherelyev
2,052 PointsThanks. Fixed it. Still, have two exceptions: Traceback (most recent call last): File "", line 23, in test_exception_not_raised File "/workdir/utils/challenge.py", line 24, in execute_source exec(src) File "", line 3 if len(product_idea) < 3: ^ TabError: inconsistent use of tabs and spaces in indentation
Double checked all the spaces. Can't find the reason for this exception.
Steven Parker
231,275 PointsSteven Parker
231,275 PointsI can't really check that without having the code formatted for Markdown (like the first example). But I do know that Python will work with tabs or spaces, but you can't mix them in the same file.