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
kevin cleary4,690 Points
I tried my code in the python shell, and it does what the instructions call for. But, the challenge says it is wrong.
What is wrong with My 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 '''
Ryan Ruscett23,309 Points
Well, your code looks to be right because it's printing the answer to the console. It's not asking you to print the answer it's asking you to return the answer. This means some function called this function and it's returning to it what it needs. It's not printing anything at this point in time. So in the console yes, yours appears to be right, but it's not actually right for which in the context the question is asking.
if len(arg1) < 5:
return "Your string is to short"
elif len(arg1) > 5:
return "Your string is to long"
This code returns the string requested based on the value being passed in depending on if it's more or less than 5. Otherwise it just returns true.
Does that make sense? If not please let me know your questions or I can try to be more clear.