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

Challenge not validating even though the answer works

Hi everyone,

This challenge isn't passing for me even though it seems my code is working when I enter it.

stringcases.py
def stringcases(string):
    uppercase_tuple = string.upper()
    lowercase_tuple = string.lower()

    split_string = string.split(" ")
    titlecase_list = []
    for word in split_string:
        titlecase_list.append(word.capitalize())

    titlecase_tuple = " ".join(titlecase_list)

    reverse_tuple = string.split()
    reverse_tuple.reverse()
    reverse_tuple = " ".join(reverse_tuple)

    return (string, uppercase_tuple, lowercase_tuple, titlecase_tuple, reverse_tuple)

1 Answer

Two things:

1) You don't need to return string. That is throwing the checker off on your values.

2) Your reverse string should reverse the entire string. You reverse the order of the words. For example 'my dog has fleas' this should be 'saelf sah god ym' instead of' fleas has dog my'