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 trialEvgeny Shilov
21,283 PointsExercise: "Bummer! Didn't get back all of the right cases"
Can't find my mistake. Could somebody help pls?
def stringcases(some_string):
some_tuple = ()
upper_string = some_string.upper()
lower_string = some_string.lower()
capitalized_string = some_string.capitalize()
reversed_string = some_string[-1::-1]
some_tuple = (upper_string, lower_string, capitalized_string, reversed_string)
print(some_tuple)
return some_tuple
1 Answer
Alexander Davison
65,469 Points- To reverse a string, you should add
[::-1]
in front of it, not[-1::-1]
. - The challenge was expecting you to use the
.title()
function, not the.capitalize()
function. They do different things (title capitalizes the first letter on every word while capitalize just capitalizes the very first one). - Why are you printing the tuple?
In order to fix this, you have to fix the above:
def stringcases(string):
uppercased = string.upper()
lowercased = string.lower()
titled = string.title()
reversed = string[::-1]
return uppercased, lowercased, titled, reversed
I hope you understand :)
~Alex
Evgeny Shilov
21,283 PointsEvgeny Shilov
21,283 PointsAlex, you are the best! Lightning fast response. Thank you
Jason Anello
Courses Plus Student 94,610 PointsJason Anello
Courses Plus Student 94,610 PointsIt's not wrong to use string[-1::-1] to reverse the string but it's not necessary to specify the start to be -1
Alexander Davison
65,469 PointsAlexander Davison
65,469 PointsOh, I didn't know XP
Thanks for responding
john larson
16,594 Pointsjohn larson
16,594 PointsAlex, thanks for your clarification on title vs capitalize. I didn't see the difference until I did a string with multiple words