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 trialAbdullah Jassim
4,551 PointsWhy is this logic wrong?
def sillycase(string):
half = int(len(string)//2)
lower_cap = string[:half].lower()
upper_cap = lower_cap[half:].upper()
cap = upper_cap
return cap
result = sillycase("treehouse")
print(result)
1 Answer
Steven Parker
231,236 PointsYou've got the right idea, but there's a few issues:
- you need to use the original string to make both parts
- you'll need to return the result of joining both parts together
- "You'll want to use the int() function or integer division, //" — but you don't need both
- you won't need to call the function, only define it
- you won't need to print anything
Abdullah Jassim
4,551 PointsAbdullah Jassim
4,551 PointsI thought the upper_cap includes the first answer, which is why I only printed the upper_cap. For e.g. -
variable = "Treehouse" lower_cap = treehouse uppercap = treeHOUSE
hence print just uppercap. Whats wrong with the logic??
Steven Parker
231,236 PointsSteven Parker
231,236 PointsIf you apply the 2nd slice to the first result, you'll get an empty string, since the first result is only "half" long.