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 (2016, retired 2019) Tuples Stringcases

Prashant Gaykar
Prashant Gaykar
1,144 Points

Got 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.

stringcases.py
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
Istvan Nonn
Istvan Nonn
2,092 Points

Hi, when you have time please mark your question as "Answered", will help others to find correct answers quickly.

2 Answers

Istvan Nonn
Istvan Nonn
2,092 Points

Hi 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] 

Slicing with a step

Prashant Gaykar
Prashant Gaykar
1,144 Points

Thanks, Istvan Nonn for 'string[::-1] ' suggestion and code worked after using title() instead of capitalize().

Yeah, capitalize() didn't work for me.

Istvan Nonn
Istvan Nonn
2,092 Points

I am glad I was able to help you and maybe others down the road. Keep up the good work.