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

Laknath Gunathilake
Laknath Gunathilake
1,860 Points

Can't seem to pass this challenge

I'm having difficulty with this challenge.

I guess my question is how do you determine the first and second half.

Also do I need a for loop for this question

silly.py
def sillycase(str):
    num=int(len(str)/2)
    return str[:num].lower()

# 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

Seth Kroger
Seth Kroger
56,413 Points

First, you have a good start with lowercasing the first part of the string. You just have to uppercase the second half in a similar fashion and concatenate the two halves back together.

Second, the comments suggest which function you should use to deal with fractions (ie. odd-length strings) which behaves slightly different than int()

Third,str is a built-in function in Python for the string type. You should see that the code window highlights it in the same color as other keywords like def and return. It can't be used as a variable name so you'll need to pick a new one.