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 trialLuke Renken
6,721 PointsNot sure what is wrong. It works when I run it in 'workspaces'.
When I run the program in work spaces it runs as expected with a test string of words, but it keeps getting rejected.
def stringcases(string):
a = string.split()
b = []
d = []
e = []
f = []
for index, item in enumerate(a):
e.append(item.upper())
for index, item in enumerate(a):
f.append(item.lower())
for index, item in enumerate(a):
b.append(item.capitalize())
for index, item in enumerate(a):
c = []
c = list(item)
c.reverse()
d.append(''.join(c))
y = tuple(b)
w = tuple(e)
x = tuple(f)
z = tuple(d)
return w, x, y, z
1 Answer
Chris Freeman
Treehouse Moderator 68,457 PointsYou are on the right track. The challenge asks for a single tuple contain the four formatted strings. The posted code returns a tuple of tuples instead.
Replace the w, x, and y tuple statements with equivalent w= " ".join(e)
type statements.
In creating the reversed string, the code is reversing the order of the words in the string. Instead in should reverse the string at the character level. This can be done with simple slice notation [::-1]
. This eliminates the need for the for
loop or join
for the z
reversal.
Good luck!! Post back if you need more help.