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

What's the wrong in my code!!

I use this code in my computer and generate a different format from a single argument, but here gave me got wrong string format

def stringcases(word):
    word_list = []
    word = word.strip()
    word_list.extend([word.upper(), word.lower(), word.capitalize(), word[::-1]])

    return tuple(word_list)

1 Answer

Marcin Lubke
Marcin Lubke
13,253 Points

Actually, I made the same mistake as you on my first approach to this challenge. Read the question in the challenge carefully, the third string you need to provide is Titlecased, not capitalized (in capitalized string only the first letter of the first word is changed, in titlecased - all words in the string are capitalized).

Also, I think your naming convention could be better. Treehouse wants to enter a longer string as an argument to stringcases function, so in my opinion argument naming it "word" is a little misleading. It would be better to name it as "string", or whatever :)

Thank you for your hint, i used title() function instead of capitalized() to convert the first letter in each word to upper case not just the first word :)