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

Sohail Mirza
seal-mask
.a{fill-rule:evenodd;}techdegree
Sohail Mirza
Python Web Development Techdegree Student 5,158 Points

why does it return a tuple

I understand the objective but i dont understand how this returns a tuple. Could someone explain why does this return tuple

stringcases.py
def stringcases(something):
    return str(something).upper(), str(something).lower(), str(something).title(), something[::-1]

2 Answers

Steven Parker
Steven Parker
231,269 Points

Any comma-separated list of things is a tuple, unless enclosed in something that explicitly creates another type (like brackets for a list, braces for a dictionary, etc.).

Hie, maybe you would want to first define your variable 'str' in the function before "return", then put everything in brackets before the commas. Example: str = (something.upper()), (something.lower())....

Then you "return" your variable...return str