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 trialAndrew Helton
4,681 PointsWorks in Python Shell, but not accepted in Code Challenge. Any ideas why?
I'm just needing to understand why my code isn't being accepted as a good answer. I've tested it out in Workspaces and it works perfectly fine.
Having said that, I am tired so maybe I'm missing a typo or something...
P.S. I've tried submitting with and without the defined variable and function call. Neither answers are accepted and no hints are given as to why my answer is wrong.
my_string = "Hi"
def just_right(my_string):
if len(my_string) < 5:
print("Your string is too short")
elif len(my_string) > 5:
print("Your string is too long")
else:
return True
just_right(my_string)
2 Answers
William Li
Courses Plus Student 26,868 PointsYour code is mostly correct. But you need to change the TWO print
statement into return
to pass the challenge.
Andrew Helton
4,681 PointsThanks, William. I didn't key in on the word 'return' in the problem. Appreciate the help!