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 trialDominick McCleary
3,012 Pointshow to do this
how would i check to see if i got this right cause i think i did index wrong
a = "hi"
def just_right(a):
if just_right(a).index(5) == False:
return "Your string is too short"
elif just_right(a).index(6) == True:
return "Your string is too long"
else:
return True
1 Answer
Sean Manners
14,816 PointsIn this challenge it looks as though they're asking you to meet the conditions using the len() function, rather than by index.
Try using len(), and using only the parameter when you call the function.
It looks as though you're definitely on the right track. Try something like this:
a = "hi"
def just_right(a):
if len(a) < 5:
return "Your string is too short"
elif len(a) > 5:
return "Your string is too long"
else:
return True
And if you're uncomfortable using index, I would definitely review their teachings on it. It can't hurt to get more comfortable with any aspect.