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 trialIan Maina
4,571 PointsWhere am I going wrong on the reversing of the strings? Any tips?
can't seem to reverse the string
def stringcases(string):
reverse = string.split()[::-1]
reverse2 = ' '.join(reverse)
tup = string.upper(), string.lower(), string.title(), reverse2
return tup
1 Answer
Steve Hunter
57,712 PointsHi there,
Just use [::-1]
for reversing. I got this:
def stringcases(word):
return (word.upper(), word.lower(), word.title(), word[::-1])
Not sure about the surrounding brackets, but it passed the challenge!
Steve.
Steve Hunter
57,712 PointsSteve Hunter
57,712 PointsYeah, the brackets are redundant; not needed.
Ian Maina
4,571 PointsIan Maina
4,571 PointsThanks man
Steve Hunter
57,712 PointsSteve Hunter
57,712 PointsNo worries - you had it all in your code; it just needed putting together!