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 trialChristopher Kell
3,499 PointsNeed guidance.
Here is the question-
Challenge Task 1 of 1
Create a new function named just_right that takes a single argument, a string.
If the length of the string is less than five characters, return "Your string is too short".
If the string is longer than five characters, return "Your string is too long".
Otherwise, just return True.
Im not really sure where to go on this one. I sort of lost my way. Could use a bit of direction if anyone can help. This code is very bad by the way. I sort of bounced around and completely lost my track of thought.
def just_right(str):
var1=just_right
var2=
while str.len() <= 5:
if var2 < var1:
print("Your string is too short")
elif > :
print("Your string is too long")
else:
just_right=True
1 Answer
Julian Gutierrez
19,201 PointsLooks like you are over thinking it just a little bit.
You've defined your just_right function correctly now you just need to write out your three conditionals that that return, not print, the values that the challenge ask for.
def just_right(x):
//Your first conditional statement goes here
//Return your string
// Your second conditional statement goes here
//Return your string
// Your third conditional statement goes here
// Return your string
There is no need to create variables in the function or use a while loop.
Christopher Kell
3,499 Pointsso I definitely feel a lot closer to solving this. thank you for your help.
Christopher Kell
3,499 PointsChristopher Kell
3,499 PointsEven pointing me to a certain area to go over again would greatly help me.