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 trialAlex Mabey
2,063 PointsWhat is wrong with this python code? I've tried it on my IDLE and it works fine....
^^^
def sillycase(a):
x = len(a) / 2
x = int(x)
y = a.upper()
z = y[:]
z = z.lower()
y = list(y)
y[0:x] = z[0:x]
y = str(y)
return y
3 Answers
Osher Jacobs
2,226 PointsThe object of this exercise if I remember rightly is to return the given string argument in partial upper and lower case. Your code returns a list of characters.
You need to join the string. To do this modify the second last line of code to:
y = ''.join(y)
and you should get the result you need.
My own code looked like this:
def sillycase(x):
lengte = (int(len(x)))
lengte_divided = (int(lengte / 2))
mod_str_1 = x[:lengte_divided].lower()
mod_str_2 = x[lengte_divided:].upper()
return(mod_str_1 + mod_str_2)
Both should pass the challenge.
Hope this helps.
Robert Gettings
1,902 PointsYou don't have to make them lists, try making two strings and adding(+) them together
Robert Gettings
1,902 Pointsslices are also usable on strings
Alex Mabey
2,063 PointsThank you for the help! Now it works perfectly.