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

help with sillycase task

I've tried so many ways of structuring this and can't pass it. seems like it should work from the study I've done with the interpretor.

silly.py
# 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"
def sillycase(word):
  word = "Treehouse"
  half = round(len(word) /2)
  new_word = word.lower[:half] + word.upper[half:]

you are not very far. why don't you remove the second line from your code, its not necessary. secondly the .lower and .upper functions should come after the slice. then return the word this one worked for me def sillycase(word) half = round(len(word)/2) return word[:half].lower() + word[half:].upper()

Thanks Dephine! I was so close and it was working in the interpreter but I guess I just wasn't understanding the instructions fully.

1 Answer

you are not very far. why don't you remove the second line from your code, its not necessary. secondly the .lower and .upper functions should come after the slice, don't forget the parathesis. then return the word, this one worked for me def sillycase(word): half = round(len(word)/2) return word[:half].lower() + word[half:].upper()