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

Hwi Han
Hwi Han
5,008 Points

Help me

I have a right output but the answer is not correct

stringcases.py
def stringcases(value):
    result=[]
    result.append(value.upper())
    result.append(value.lower())
    result.append(value.capitalize())
    re = list(value)
    reverse =""
    for v in re:
        if v.islower():
            reverse += v.upper()
        else:
            reverse += v.lower() 
    result.append(reverse)
    result = tuple(result)
    return result
Hwi Han
Hwi Han
5,008 Points

I also tried this one too. def stringcases(value): result=[] result.append(value.upper()) result.append(value.lower()) result.append(value.capitalize()) re = list(value) cnt = len(re)-1 reverse ="" start = 0 while cnt != int((len(re)-1)/2): re[cnt],re[start] = re[start],re[cnt] start +=1 cnt -=1 for v in re: reverse += v result.append(reverse) return tuple(result)

1 Answer

Hwi Han
Hwi Han
5,008 Points

It worked!! Thanks a lot.