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

stringcases reversed string is working fine in workspaces

My stringcases code is working fine in workspaces but the code challenge is telling me that the function is returning the wrong value for the reversed case string.I can't seem to figure out where I am failing.

stringcases.py
def stringcases(my_string):
    uppercase=my_string.upper()
    lower=my_string.lower()
    title=my_string.title()
    def reverse_case(a_string):
        reversed_case=''
        upper_alpha=('A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z')
        for letter in a_string:
            if letter in upper_alpha:
                letter=letter.lower()
            else:
                letter=letter.upper()
            reversed_case+=letter
        return reversed_case


    return(uppercase,lower,title,reverse_case(my_string))

1 Answer

Steven Parker
Steven Parker
231,269 Points

:warning: Be careful about testing a challenge in the workspace..

If you have misunderstood the challenge, it's also very likely that you will misinterpret the results.

In this case, you're reversing the letter case for the last variation. But what the challenge is asking for is a variation where the string itself is reversed. For example, if the string was "grab" then the 4th variation would be "barg".

Thanks a lot Steven!