Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

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
216,149 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.