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

stringcases.py function returning a tuple with case changes from a string input

Not sure what's wrong with code

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?

def stringcases(string):
  up = string.upper()
  lo = string.lower()
  tit = string.title()
  for itb in string:
    rev = itb[::-1]
  stringcases = (up, lo, tit, rev)
  return stringcases

1 Answer

Kourosh Raeen
Kourosh Raeen
23,733 Points

To reverse the string you don't need the for loop. Just do: rev = string[::-1]

I could have sworn I tried that.. GRRRRrrrrrRRR! Haha

Thanks Kourosh!