Python Python Collections 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
133,975 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.