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

Alejandro Byrne
Alejandro Byrne
2,562 Points

Hi, need help on a challenge

So I honestly don't know why my response doesn't complete the challenge. I tried it out in workspaces, and it worked. What's my problem. (for titlecase, I originally replaced it with string[0].upper() + string[1:])

stringcases.py
def stringcases():
    upper = string.upper()
    lower = string.lower()
    titlecase = string.title()
    reverse = string[-1::-1]
    final = upper, lower, titlecase, reverse
    return final

1 Answer

Stuart Wright
Stuart Wright
41,120 Points

Your only mistake is that you aren't passing anything into your function (see first line in solution below):

def stringcases(string):
    upper = string.upper()
    lower = string.lower()
    titlecase = string.title()
    reverse = string[-1::-1]
    final = upper, lower, titlecase, reverse
    return final

As an aside, this also works for the reverse line:

    reverse = string[::-1]
Alejandro Byrne
Alejandro Byrne
2,562 Points

Ohhh, myyy, goodness. Stupid mistake. Anyway, thanks!