Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

Python Python Collections (2016, retired 2019) Tuples Stringcases

Brandon Galde
Brandon Galde
12,741 Points

I don't know which case is not returning correctly

I fail this challenge with error: Bummer! Didn't get back all of the right cases!

I get all uppercase with arg.upper(), all lowercase with arg.lower(), titlecase with arg.capitalize(), and reversed with ''.join.([arg(x) for x in range(0, len(x)).reversed()]).

I have also tried the reversed method with t = list(arg); t.reversed(); str(t) (or even ''.join(t). So I'm not understanding what is failing here. (and I am returning a tuple).

stringcases.py
def stringcases(arg):
    return arg.upper(), arg.lower(), arg.capitalize(), ''.join([arg[x] for x in range(0, len(arg)).__reversed__()])

1 Answer

Umesh Ravji
Umesh Ravji
42,361 Points

Hi Brandon, the reversing is fine, its the capitalize function that isn't giving you what you want. There's a small difference between capitalize and title functions, and there most likely strings with spaces in them, giving you the incorrect results using capitalize.

Brandon Galde
Brandon Galde
12,741 Points

That was it! thanks for the reply!