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 trial

Python Python Collections (2016, retired 2019) Tuples Stringcases

Where am I going wrong on the reversing of the strings? Any tips?

can't seem to reverse the string

stringcases.py
def stringcases(string):

    reverse = string.split()[::-1]
    reverse2 = ' '.join(reverse)

    tup = string.upper(), string.lower(), string.title(), reverse2

    return tup

1 Answer

Hi 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.

Yeah, the brackets are redundant; not needed.

Thanks man

No worries - you had it all in your code; it just needed putting together! :+1: :smile: