Python Python Collections Tuples Stringcases

P Hoyt
PRO
P Hoyt
Pro Student 1,097 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
94,464 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
Pro Student 1,097 Points

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

Steven Parker
Steven Parker
94,464 Points

P Hoyt — Glad to help. You can mark the question solved by choosing a "best answer".
And happy coding!