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

P Hoyt
P Hoyt
1,555 Points

Challenge task 1 of 1 - function 'Stringcase'. Don't know why code is not passing. It works outside of Treehouse.

Maybe I'm not understanding what is meant by 'reversed'. What I'm doing is flipping the case of the original string, letter by letter.

stringcases.py
def stringcases(string):
    reversed = ""
    for i in string:
        if i.islower():
            i = i.upper()
        else:
            i = i.lower()
        reversed = reversed + i
    new_tuple = (string.upper(),string.lower(), string.title(), reversed)
    return(new_tuple)
stringcases("Abraham Lincoln")

1 Answer

Steven Parker
Steven Parker
231,269 Points

What they mean by "reversed" has nothing to do with case, but with the order of the letters.

For example: "evil" reversed would be "live".

P Hoyt
P Hoyt
1,555 Points

Thanks Steven - found that out right after I posted the question.