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 trialJames McCombe
Courses Plus Student 1,601 PointsWhy didn't this code run when string was ("like this")?
I worked out that i needed to remove the quotations in the end, but I wondered, why wouldnt it pass me if I used a string inside quotations?
See my example.
def just_right("a string"):
if len("a string") < 5:
return "Your string is too short"
elif len("a string") >5:
return "Your string is too long"
else:
return True
1 Answer
Chris Freeman
Treehouse Moderator 68,441 PointsThe parameters of a function must be able to receive the parameter used to call the function. A string is a immutable object meaning it can not be changed (mutated) so it cannot be a parameter.
Post back if you need more details.