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 trialHwi Han
5,008 PointsHelp me
I have a right output but the answer is not correct
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
1 Answer
james south
Front End Web Development Techdegree Graduate 33,271 Pointstry the title method instead of capitalize. also a simple way to reverse a string is to use slice notation, myString[::-1] = gnirtSym.
Hwi Han
5,008 PointsIt worked!! Thanks a lot.
Hwi Han
5,008 PointsHwi Han
5,008 PointsI 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)