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
wafic fahme
3,309 Pointsin challenge string lengths I am getting a bummer although the code is correct
def just_right(string): string = str() if len(string) < 5: print("Your string is too short")
elif len(string) > 5:
print("Your string is too long")
else:
return True
3 Answers
wafic fahme
3,309 PointsI solved it I solved it thanks a lot cuz it was not just the return but the assignment of the argument was inside the function but it was supposed to be outside.
can you let me know why?
Jennifer Nordell
Treehouse TeacherAlthough you haven't linked the challenge here, I think I remember it. I feel fairly certain that the challenge asks you to return the strings, not print them. If this turns out to not be the case, could you please link the challenge?
wafic fahme
3,309 PointsThis is the case but still not working, here is the challenge link:
https://teamtreehouse.com/library/python-basics/number-game-app/string-length
python'''
def just_right(string): string = str() if len(string) < 5: return "Your string is too short"
elif len(string) > 5:
return "Your string is too long"
else:
return True
Name:GoogleSearch orJonathan Sum
5,039 PointsName:GoogleSearch orJonathan Sum
5,039 PointsAre u talking about the code you posted"string = str()"? I don't know why u need"str()". Str() is a function to change a int or variable into a string.
Name:GoogleSearch orJonathan Sum
5,039 PointsName:GoogleSearch orJonathan Sum
5,039 PointsTatiana Vasilevskaya
Python Web Development Techdegree Graduate 28,600 PointsTatiana Vasilevskaya
Python Web Development Techdegree Graduate 28,600 Pointsstring = str()should'n be there. It looks like it assigns the variablestringto an empty string.