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 (Retired) Slices sillyCase

Brian S.
Brian S.
3,176 Points

Little help to pass please

I'm sure i am misunderstanding here.... but, if 'treehouse' (9 letters, odd) should be 'treeHOUSE', then it's implied that given an odd number of letters, more should be upper than lower. Following these rules, when I input my code, I get an error that says 'kenneth' (7 letters, odd) should be 'kennETH', implying that given an odd number of letters, more should be lower. Any suggestions, or clarifications? Thank you.

silly.py
def sillycase(word):
    half = len(word) // 2 

    if len(word) % 2 != 0: #its odd
        return word[0:half].lower() + word[half:].upper()
    else:   # its even
        half = len(word) // 2
        return word[0:half].lower() + word[half:].upper()
        print('even')# The first half of the string, rounded with round(), should be lowercased.
# The second half should be uppercased.
# E.g. "Treehouse" should come back as "treeHOUSE"

1 Answer

Steven Parker
Steven Parker
231,236 Points

:point_right: The challenge asks for the "first half of the string, rounded with round()..."

:x: But you calculated your half using the floored division operator ("//").

If you calculate the half size as suggested, you should pass the challenge. Also, you won't need to make a special case for even vs. odd.