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

Andres Felipe
Andres Felipe
11,337 Points

what is wrong with this code, when I run it I see it gives what is expected.

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

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

2 Answers

Steven Parker
Steven Parker
231,269 Points

Perhaps your testing was not quite what the verifier might use. It would be easy to miss the issue if you were only using a single word to test. Try using a string that contains several words.

Yusay Safadi
Yusay Safadi
8,113 Points

you should use s.title() for the titlecased version instead of s.capitalize() because s.capitalize() would do the following:

lets say the string is "hello my name is Peter"

with s.capitalize() you are changing that string to: "Hello my name is Peter"

and with s.title() it would change to the form that the want the string: "Hello My Name Is Peter

I hope i could help you