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 trialKirome Thompson
5,350 PointsCan anyone help me figure out whats wrong with my code to return uppercase, lowercase, titlecase, and reverse?
the method I have written works on my powershell not with the treehouse compiler. what I have to do is create a function that takes a string makes tuples of that string in uppercase, lowercase, titlecase and in reverse. Can't see what I've done wrong when my code works in powershell.
def stringcases(a_string):
upper = tuple([a_string.upper()])
lower = tuple([a_string.lower()])
title = tuple([a_string.title()])
reverse = tuple([a_string[::-1]])
return tuple([upper, lower, title, reverse])
3 Answers
KRIS NIKOLAISEN
54,972 PointsThere is no need to convert each individual string into a tuple
def stringcases(a_string):
upper = a_string.upper()
lower = a_string.lower()
title = a_string.title()
reverse = a_string[::-1]
return upper, lower, title, reverse
Otherwise your code looks good
Kirome Thompson
5,350 Pointsthanks a lot appreciate the help
Ahmed Khairi
2,113 Pointsor you can do like this to make the code more pythonic:
def stringcases(a_string):
return a_string.upper(),a_string.lower(), a_string.title(), a_string[::-1]