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 trialPrashant Gaykar
1,144 PointsGot the wrong string(s) for:
Bummer: Got the wrong string(s) for
code run as expected on my machine also i am returning the tuple as asked in question but don't know what's getting wrong here. Please help.
def stringcases(data_str):
uppercase = data_str.upper()
lowercase = data_str.lower()
titlecase = data_str.capitalize()
rev_list = list(data_str)
rev_list.reverse()
reversecase = ''.join(rev_list)
return uppercase,lowercase,titlecase,reversecase
2 Answers
Istvan Nonn
2,092 PointsHi Prashant Gaykar so your code seems to work fine, your output is:
('LOREM IPSUM DOLOR SIT AMET.', 'lorem ipsum dolor sit amet.', 'Lorem ipsum dolor sit amet.', '.tema tis rolod muspi meroL')
I tried titlecase = data_str.title() and it worked
Also, I will ask you to try and rethink your code and see if you can make it shorter. For the reverse part use the slice method on a string.
string[::-1]
Prashant Gaykar
1,144 PointsThanks, Istvan Nonn for 'string[::-1] ' suggestion and code worked after using title() instead of capitalize().
f4u57
6,743 PointsYeah, capitalize() didn't work for me.
Istvan Nonn
2,092 PointsI am glad I was able to help you and maybe others down the road. Keep up the good work.
Istvan Nonn
2,092 PointsIstvan Nonn
2,092 PointsHi, when you have time please mark your question as "Answered", will help others to find correct answers quickly.