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

Crystal Shelton
PLUS
Crystal Shelton
Courses Plus Student 1,520 Points

I don't understand why this works in workspace but the challenge tells me it is wrong

Please see my string cases code and help me understand why the challenge is saying it is the wrong output. It is supposed to return a tuple.

stringcases.py
# 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?
my_string = "I am what I am"

def stringcases(my_string):
  a = my_string.upper()
  b = my_string.lower()
  c = my_string.title()
  my_list = my_string.split()
  my_list_reverse = my_list[len(my_string)::-1]
  d = " ".join(my_list_reverse)
  e = (a, b, c, d)
  return e

stringcases(my_string)

2 Answers

Seth Kroger
Seth Kroger
56,414 Points

I think by "reverse a string" it's asking to the reverse it character by character, not word by word. Essentially "ma I tahw ma I", not "am I what am I".