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 trialJoeseph Wolfe
Courses Plus Student 1,010 PointsI am not understanding what I did wrong, this seems to work in my local interpreter.
The only message I see returned back is "Bummer!, Try again!" which is not helpful in determining what I did wrong :(.
# 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(my_str):
tup_up = tuple(my_str.upper())
tup_lower = tuple(my_str.lower())
tup_title = tuple(my_str.title())
reverse_str = my_str[::-1]
tup_rev = tuple(reverse_str)
return tup_up, tup_lower, tup_title, tup_rev
string = 'this is a test string'
stringcases(string)
1 Answer
Alexander Davison
65,469 PointsTwo problems:
- Don't translate the strings into tuples! Get rid of every existence of the
tuple()
function. Only keep the last tuple (the one you return) - Don't call the function! The code challenge does that automatically for you :)
With all of those fixed, your code should look like:
def stringcases(my_str):
uppercase = my_str.upper()
lowercase = my_str.lower()
titlecase = my_str.title()
reverse = my_str[::-1]
return uppercase, lowercase, titlecase, reverse
Good luck! ~alex
Salvatore Architetto
1,506 PointsSalvatore Architetto
1,506 PointsHey Alexander, just wondering why adding the Tuple function is function is incorrect? In my code I was using enumerate() before word.upper() etc. Will using just .upper() .lower() bring back a tuple regardless? Thanks