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

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,386 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.

That was it! thanks for the reply!