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 trialAshmit Pathak
4,441 PointsI think may be iam right but the result is BUMMER!
plz tell me where am i wrong or the best is plz give your solution so that i could know what's wrong with my code
def stringcases(strings):
for string in strings:
return string.lower()
for string in strings:
return string.upper()
for string in strings:
return string[0].upper()
for string in strings:
return string[::-1]
Jennifer Nordell
Treehouse TeacherI will give you a hint here, though. You should definitely test this in a workspace. I can promise you that the only thing you will get back is a lower case string and this is because a function ceases execution when a return
statement is hit
Ashmit Pathak
4,441 Pointsso what to do next ma'am
Ashmit Pathak
4,441 Pointsplz be a lil bit brief so that i can understand what's going wrong with my code...Like i understood i am going wrong with return so what should i do to get the answer iam tested it in workspace iam not able to get the capitalized and reverse one plz help..
2 Answers
Jennifer Nordell
Treehouse TeacherHi there, Ashmit! I will try again with some addition tips:
- This challenge can be completed in two lines of code.
- The function is not taking multiple strings. It is only taking one string. A loop is unnecessary.
- The uppercase version of that string, the lowercase version, the title case version and the reverse version should all be returned together on the same line
- You should return a list with the different versions inside and separated by commas
- Your code is currently missing the title case
- If I sent in "Hello", I would expect to get back a tuple containing "hello", "HELLO", "Hello", "olleH"
Give it another go and test it in the workspace!
Chris Freeman
Treehouse Moderator 68,457 PointsThe flow of your code needs work. In the first for
loop, the return
will stop the function execution in the first iteration.
Sometimes it helps to understand the challenge by making sure you are fully reading all the text.
The challenge asks you to create a function that "takes a single string" and returns "a tuple of different string formats".
Using a for
loop on a string will iterate over ever individual letter.
Instead, capture each version of the modified string in a different variable, then return a tuple containing these variables. The solution can be more compact than this but it's helpful to understand how to do each step explicitly before jumping to shortcut notation.
Post back if you need more help. Good luck!!!
Michael Hulet
47,913 PointsMichael Hulet
47,913 PointsTo those answering this question in the future, please note that it's frowned-upon to post code that can be copied and pasted into a challenge and pass unmodified, and any such code will be redacted