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

Kaci Jenkins
Kaci Jenkins
860 Points

help with sillycase

This task is really challenging me. Could someone help me out without giving me just the solution? I want to understand where I'm going wrong.

sillycase.py
def sillycase("treehouse"):
    word1 = list(sillycase)
    sillycase = int(word1)
    word2 = word1[-5:]
    word2.upper
    word3 = word1[:3]
    sillycase = word2 + word3
return sillycase

1 Answer

Luke Strama
Luke Strama
6,928 Points

The first place I would probably start is figuring out what should be going into the argument of the function. So what is the purpose of the blank space here...

def sillycase(_________):

Your first line within the function looks good, as it will give you a way to separate out parts of the string into characters become changeable. You'll find to find out how many items are now in that list to figure out the middle point of your word. You would then wrap the int() function around that to prevent words with an odd number of letters in it from returning decimals. (or floats)

You can then apply that middle point number to slice the list from left and right to get both halves of the word. And then figure out how to join the first half and second half of the letters into a string again and apply the lower() and upper() functions to make it happen.

Hopefully that makes sense!

Greg Kaleka
Greg Kaleka
39,021 Points

Just a quick point of clarification - your first line inside the function needs to turn the passed-in string into a list. The name of the function itself can't be used inside the function - it doesn't mean anything in that scope.