Python Python Collections (2016, retired 2019) Slices sillyCase

Function naming incorrect on Python Collections sillycase challenge making the code checker unable to find my method.

I think the code checker has some other method name it is looking for instead of the 'sillycase' function name requested in the problem description. This is resulting in an error "Couldn't find 'sillycase'." being thrown.
def sillycase(string):
    split_loc = int(len(string))
    return lower(string[:split_loc]) + upper(string[split_loc:])

2 Answers

54,333 Points

If you run your code in a workspace you'll receive a better error message.

NameError: name 'lower' is not defined

This is why the function can't be found. According to the python docs use str.lower() to convert to lowercase - meaning (string[:split_loc]).lower(). The same error will occur with upper.

You also need to work with halves of the string so split_loc should include divide by 2.

Robin Goyal
Robin Goyal
4,581 Points

So there are no built-in functions in Python that are called upper and lower. These are methods that are tied to the Python str object. You have to do str.upper or str.lower.

>>> string = "Hello"
>>> string.upper()
>>> string.lower()