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

Jennifer Sherwood
Jennifer Sherwood
896 Points

Error says "int() or // will be needed". I've tried both but still getting the error.

I've written this challenge about 10 different ways but keep getting the same error. I tried running it on a different rpl and it worked. Please advise.

sillycase.py
def sillycase(string):
    half_length = int(len(string) / 2)
    string_left = string[:half_length]
    string_right = string[half_length:]
    sillycase_string = string_left.lower + string_right.upper
    return sillycase_string

3 Answers

diogorferreira
diogorferreira
19,363 Points

The errors is that you have to call the functions, you can't just add them. So it would have to be both .upper() and .lower()

def sillycase(string):
    half_length = int(len(string) / 2)
    string_left = string[:half_length]
    string_right = string[half_length:]
    sillycase_string = string_left.lower() + string_right.upper()
    return sillycase_string

Hope it helps!

Jennifer Sherwood
Jennifer Sherwood
896 Points

I'm sorry, but I don't think I know what you mean. I thought I did but what I tried didn't work.

diogorferreira
diogorferreira
19,363 Points

I'm not sure what is wrong then, whenever I try your code with the changes it passes the challenge?

Jennifer Sherwood
Jennifer Sherwood
896 Points

What I mean is, that I don't understand what you're telling me to do in your first response, therefore I can't make the changes to pass the challenge.

I tried what I thought you meant and I got "can't find sillycase"

Jennifer Sherwood
Jennifer Sherwood
896 Points

SMH - I knew I was tired last Friday. Three minutes back at it, I see what I was missing ().