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

John Berglund
John Berglund
1,442 Points

Why isn't this sillycase function working?

If I try this with the string 'treehouse' it returns treeHOUSE as described in the instructions. Yet it gives me "Bummer: Try again!". Thanks in advance!

sillycase.py
def sillycase(string):
    half = len(string) // 2
    first = string[:half]
    second = string[half:]
    third = first.lower() + second.upper()
    return third

2 Answers

it's working for me. How are you calling the function?

This is what I did:

def sillycase(string):
    half = len(string) // 2
    first = string[:half]
    second = string[half:]
    third = first.lower() + second.upper()
    return third

print(sillycase("today is the day"))

This is what I get back

treehouse:~/workspace$ python testing.py
today is THE DAY

John Berglund
John Berglund
1,442 Points

It seemed to me earlier as it was enough without the last line. I guess I'm lacking a lot of the basics still. Thank you for the quick response!