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 (Retired) Tuples Stringcases

Anthony Inman
Anthony Inman
2,320 Points

Not sure what output is expected for this challenge? Is it asking for a entire string to be formatted in first upper....

Is it asking me to return four different versions of the entire string or is it asking me to split the string and supply upper for list[0], then lower for list[1] .....etc?

# Handy functions:
# .upper() - uppercases a string
# .lower() - lowercases a string
# .title() - titlecases a string
# There is no function to reverse a string.
# Maybe you can do it with a slice?
def stringcases(value):
  str_list = value.split()
  upper_str = str_list[0].upper()
  lower_str = str_list[1].lower()
  cap_first = str[2].capitalize()
  reverse = str_list[3][::-1]
  my_tpl = (upper_str,lower_str,cap_first,reverse)
  return my_tpl

2 Answers

Dan Johnson
Dan Johnson
40,533 Points

It wants four different versions of the entire string, no split required.

Kenneth Love
Kenneth Love
Treehouse Guest Teacher

Yep. You're returning a tuple with 4 items in it, each item being one of those versions of the string.