Python Python Collections Slices sillyCase

Leo Marco Corpuz
Leo Marco Corpuz
15,782 Points

sillycase challenge

Not sure if this is the right approach. I checked everything and it makes sense.

sillycase.py
def sillycase(word):
     middle=len(word)//2
     lowerHalf=word[:middle].lower()
     upperHalf=word[middle:].upper()
     newWord=lowerHalf+upperHalf
return newWord

1 Answer

diogof
diogof
4,388 Points

Your code is correct except that the return is outside the function and so will return an error. I also found that it has an extra space (5) in each line inside the function. So I just corrected it into this:

def sillycase(word):
    middle=len(word)//2
    lowerHalf = word[:middle].lower()
    upperHalf = word[middle:].upper()
    newWord = lowerHalf+upperHalf
    return newWord