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

Help with tuples and strings...

What's wrong?

stringcases.py
def stringcases(string):
    return string.upper(), string.lower(), string.capitalize(), string[::-1]

1 Answer

Dave StSomeWhere
Dave StSomeWhere
19,822 Points

The challenge is asking for

Titlecased (first letter of each word is capitalized)

You function outputs the following incorrect tuple:

#  your function
def stringcases(string):
    return string.upper(), string.lower(), string.capitalize(), string[::-1]

print(stringcases('abc DEF gHi jkL'))  #  simple silly test case

#  your output
('ABC DEF GHI JKL', 'abc def ghi jkl', 'Abc def ghi jkl', 'Lkj iHg FED cba')

#  desired output
('ABC DEF GHI JKL', 'abc def ghi jkl', 'Abc Def Ghi Jkl', 'Lkj iHg FED cba')

Thanks! Why are we not able to see all of the test cases and outputs? That would be a lot more useful then asking for every test case fail what is wrong?

Dave StSomeWhere
Dave StSomeWhere
19,822 Points

Not sure, but that was just a test case I created. My guess is that you need to create your own test cases and test your own code. To me, testing is the most important part of coding (just one goofball's opinion) :smile: