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

Vladimir Lapcevic
Vladimir Lapcevic
6,363 Points

Please advise me what is wrong with this code. Thanks

Please advise me what is wrong with this code. Thanks

stringcases.py
def stringcases(some_string):
    new_string = enumerate(some_string)
    return new_string.uppercase()

1 Answer

rydavim
rydavim
18,813 Points

Okay, so Python isn't my strongest language, but there are a couple of issues I'm seeing.

def stringcases(some_string): # Yup, looks good.
    new_string = enumerate(some_string) # Why are you enumerating here?
    # enumerate() here would just return each index and character of the string.
    return new_string.uppercase() # The syntax here would just be upper(), no case.

Additionally, they are asking for all of the different cases detailed - not just one. So you'll need to return a tuple of all of the different modified strings: upper, lower, title, and reversed.

So, think of it as something like...

def stringcases(some_string):
    # 1. Create an all uppercase version of the string - syntax upper()
    # 2. Create an all lowercase version of the string - syntax lower()
    # 3. Create a titlecase version of the string, each word should be capitalized - syntax title()
    # 4. Create a reversed version of the string. This does not have a function, you will need to build it.
    #    Hint: There are several ways to do this. Maybe try using .join and reversed()?
    # 5. Return a tuple of all of the above. Tuples are immutable objects - syntax example = (1, 2, 3)

Try using the pseudo-code above to complete the challenge. If you're still having trouble, let me know and we can walk through a solution. Happy coding!