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

hubert chen
hubert chen
12,761 Points

String case Code Challenge

What is wrong with my code, it keeps telling me it got the wrong output.

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(hello):
  sting='hello'
  case=(sting.upper(),sting.lower(),sting.title(),sting[::-1])
  (a,b,c,d)=case

  return (a,b,c,d) 

2 Answers

Thomas Kirk
Thomas Kirk
5,246 Points

Hi Hubert,

The question asks you to create a function that takes any string. Your code will only return the correct answer for the word 'hello', regardless of what is entered into the function.

def stringcases(sting):
    case=(sting.upper(),sting.lower(),sting.title(),sting[::-1])

    return case
def stringcases(s):
    a,b,c,d = s.upper(), s.lower(), s.title(), s[::-1]
    return(a,b,c,d)