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

How to get a single word from a string and put it in a tuple?

Hey Im stuck on this assignment. I don't know how to get a single word out of a string and put it in a tuple. Can someone please show me how this is done?

stringcases.py

1 Answer

Grigorij Schleifer
Grigorij Schleifer
10,365 Points

Hi Marco,

def stringcases(single_string):
    return (single_string.upper(),
            single_string.lower(),
            single_string.title(),
            single_string[::-1])

The method returns a tuple with four items. First three use build in python functions and the last one is a nice sliced one :smile:

Does this help?

Hey!

Thanks alot, I was thinking way too difficult. I didn't know you could just make a tuple like that but now I do so thanks :)!!

Grigorij Schleifer
Grigorij Schleifer
10,365 Points

Hey Marco, you are very welcome. Keep up the hard work :sunglasses: