Python Python Collections (2016, retired 2019) Slices sillyCase

Michael Morale
Michael Morale
2,702 Points

sillycase

I'm still stuck on this. Any ideas?

sillycase.py
def sillycase(word):
    word = apples
    halfway = (len(word) // 2)
    word.lower([0:halfway])
    word.upper([halfway:])
    return(word)

1 Answer

Steven Parker
Steven Parker
177,888 Points

You're close, but you don't want to overwrite the argument right at the beginning. Plus, nothing named "apples" has been defined.

Also, your slice syntax isn't quite right. The brackets with slice parameters need to come after the string they apply to instead of being inside the parentheses of the method call. Those methods don't take arguments anyway.

Then, you'll need to save those slices where you can combine and return them, or make them be part of the return statement directly.

Michael Morale
Michael Morale
2,702 Points

I got it! This is what I did:

def sillycase(word):
        halfway = len(word) // 2
        final_word = word[0:halfway].upper() + word[halfway:].lower()
        return final_word