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!
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

jahabeebs
3,804 PointsSo, these code snippets look identical but only one works...
So, I was working on the Python Collection module and the final challenge was called sillyCase. The objective of the challenge is to define a function called sillycase which takes a string argument. Then, take the first half of a given string and return it in lowercase letters, and take the last half of a given string and return it in uppercase letters. My code was identical to another user's code, but only his code worked in the compiler to solve the problem. What's the deal?
My code:
def sillycase(string):
midpoint = round(len(string)/2)
first_half = string[:midpoint].lower()
second_half = string[midpoint:].upper()
return first_half + second_half
His code:
def sillycase(string):
half = round(len(string)/2)
first_half = string[:half].lower()
last_half = string[half:].upper()
return first_half + last_half
1 Answer

Louise St. Germain
19,424 PointsGood question... both of these code snippets worked for me when I plugged them into the challenge (as you might expect!). I'm not sure why only one of them was working for you. If you copy/paste your code from this forum post into the challenge, do you still have the same problem?
Sometimes it's a problem with a mixture of tabs and spaces, but I don't see that here, so I'm not sure what the issue might have been.
jahabeebs
3,804 Pointsjahabeebs
3,804 PointsYes, after I refreshed the workspace they both worked. Thank you!