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

Sillycase challenge

So I saw the related solution at https://teamtreehouse.com/community/is-there-a-different-approach-to-solving-this-challenge and realized I did this in a very roundabout way, but I do get the correct result when I run it in the Python shell in my Terminal (I tried a couple different strings). Is there a reason why this Treehouse isn't accepting this? Thanks.

sillycase.py
def sillycase(input):
    length = len(input)
    numbers = range(0, length)
    index_length = int(len(numbers)) - 1
    print index_length

    first_half = input[0:index_length // 2].lower()
    second_half = input[index_length // 2:].upper()
    print first_half + second_half

sillycase("Treehouse")

This isn't working for Treehouse either (but it is in Terminal):

def sillycase(input): half = len(input) // 2

first_half = input[:half].lower()
second_half = input[half:].upper()

sillycase("Treehouse")

josephr
josephr
18,877 Points

Assuming you are getting the correct output elsewhere, I assume the problem is that your function prints instead of returns.

1 Answer

That was it, Joseph R. Thank you!