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 trial

Python Python Collections (2016, retired 2019) Slices sillyCase

Abdullah Jassim
Abdullah Jassim
4,551 Points

Why 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
Steven Parker
231,236 Points

You'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
Abdullah Jassim
4,551 Points

I 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
Steven Parker
231,236 Points

If you apply the 2nd slice to the first result, you'll get an empty string, since the first result is only "half" long.