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 trialaditya yadav
1,505 PointsWhere I am doing it wrong
Pls help me with the code
def just_right(string):
if len(string)<5:
print('Your string is too short')
elif len(string)>5:
print('Your string is too long')
else:
return True
1 Answer
sepehr akbarzadeh
Python Web Development Techdegree Student 1,762 PointsIn python you must regard indentation. Also you must write return instead of print
def just_right(string):
if len(string) < 5:
return 'Your string is too short'
elif len(string) > 5:
return 'Your string is too long'
else:
return True
just_right('your string')
aditya yadav
1,505 Pointsaditya yadav
1,505 PointsThank you for the answer , I know it is correct , but the code challenge is still giving error
andren
28,558 Pointsandren
28,558 PointsIn addition to the indentation error that sepehr akbarzadeh pointed out you have another issue in your code. Namely that you are printing out the strings, not returning them, which is what the task's instruction asks you to do.
If you change
print
toreturn
like this:Then your code will work.
sepehr akbarzadeh
Python Web Development Techdegree Student 1,762 Pointssepehr akbarzadeh
Python Web Development Techdegree Student 1,762 Pointsyeah, you are right
Thank you
pardon me for my bad answer.
andren
28,558 Pointsandren
28,558 PointsDon't worry, your answer is not bad as you had no way of knowing about that issue unless you went and read the challenge's instructions . I have just answered a bunch of question about this challenge in the past so I'm quite familiar with what the challenge requires.
Though it is often a good idea to verify that the solution you post passes the challenge before you post it as an answer, that's my personal policy, and it has stopped me from posting incomplete answers quite a number of times.
When a post is associated with a challenge you can go to the challenge just by clicking on the "View Challenge" button that is found near the top of the page. So it's pretty easy to verify your solution and to check on the instructions of the task.
sepehr akbarzadeh
Python Web Development Techdegree Student 1,762 Pointssepehr akbarzadeh
Python Web Development Techdegree Student 1,762 PointsThank you for your complete answer, i'm novice in TeamTreeHouse community.
i got the point.