curriculum/challenges/english/blocks/learn-list-comprehension-by-building-a-case-converter-program/657f0353c9523d7d896873ea.md
Inside the main() function, replace the pass statement, with a call to the convert_to_snake_case() function, passing the string 'aLongAndComplexString' as input.
To display the output, pass the function call as the argument to the print() function.
You should call convert_to_snake_case() inside the main() function and pass 'aLongAndComplexString' as input to the function.
({
test: () => {
const transformedCode = code.replace(/\r/g, "");
const main = __helpers.python.getDef("\n" + transformedCode, "main");
const { function_body } = main;
assert.match(function_body, / +print\s*\(\s*convert_to_snake_case\s*\(\s*("|')aLongAndComplexString\1\s*\)\s*\)/);
}
})
You should not have pass in your main function.
({
test: () => {
const commentless_code = __helpers.python.removeComments(code);
const transformedCode = commentless_code.replace(/\r/g, "");
const main = __helpers.python.getDef("\n" + transformedCode, "main");
const { function_body } = main;
assert.notMatch(function_body, /pass/);
}
})
def convert_to_snake_case(pascal_or_camel_cased_string):
snake_cased_char_list = []
for char in pascal_or_camel_cased_string:
if char.isupper():
converted_character = '_' + char.lower()
snake_cased_char_list.append(converted_character)
else:
snake_cased_char_list.append(char)
snake_cased_string = ''.join(snake_cased_char_list)
clean_snake_cased_string = snake_cased_string.strip('_')
return clean_snake_cased_string
--fcc-editable-region--
def main():
pass
--fcc-editable-region--