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

Made some corrections but i still get bummered.

HERE IS THE QUESTION DETAILS

I need you to create a new function for me.

This one will be named sillycase and it'll take a single string as an argument.

sillycase should return the same string but the first half should be lowercased and the second half should be uppercased.

For example, with the string "Treehouse", sillycase would return "treeHOUSE".

Don't worry about rounding your halves, but remember that indexes should be integers. You'll want to use the int() function or integer division, //.

sillycase.py
def sillycase(string):
    stringy = list(string)
    string_size = len(stringy)
    half_string =int(string_size/2)
    first_half ="".join(stringy[:half_string])
    second_half ="".join(stringy[half_string:])
    first_lower =first_half.lower()
    second_upper =second_half.upper()
    final_stringy = first_lower+ second_upper
    return final_stringy

check for some trailing lines and indentation.

your code is being accepted just fine.

1 Answer

Steven Parker
Steven Parker
231,269 Points

Your code is bit more complicated than needed (hint: you don't need to convert to and from lists), but it does pass the challenge. However, I did notice some odd things in the syntax coloring of your example which made me wonder of there might be some unseen characters in it that might be throwing things off.

Here's your code again, but as you can see the syntax coloring is more typical for Python code:

sillycase.py
def sillycase(string):
    stringy = list(string)
    string_size = len(stringy)
    half_string =int(string_size/2)
    first_half ="".join(stringy[:half_string])
    second_half ="".join(stringy[half_string:])
    first_lower =first_half.lower()
    second_upper =second_half.upper()
    final_stringy = first_lower+ second_upper
    return final_stringy