curriculum/challenges/english/blocks/learn-list-comprehension-by-building-a-case-converter-program/657efa642593c5746acc5c81.md
Inside the if statement body, you need to convert any uppercase character to lowercase and prepend an underscore to this lowercase character.
Use the .lower() string method to convert uppercase characters to lowercase characters. Then, prepend an underscore to the character. Assign the results to a variable named converted_character.
You should assign the modified character to a variable named converted_character.
({
test: () => {
assert(runPython(`
converted_character_variable = (
_Node(_code)
.find_function("convert_to_snake_case")
.find_for_loops()[0]
.find_ifs()[0]
.find_variable("converted_character")
)
converted_character_variable.is_equivalent(
"converted_character = '_' + char.lower()"
) or converted_character_variable.is_equivalent(
"converted_character = f'_{char.lower()}'"
)
`));
}
})
You should not have pass in your if statement.
({
test: () => {
assert(runPython(`not _Node(_code).find_function("convert_to_snake_case").find_for_loops()[0].find_ifs()[0].has_stmt("pass")`));
}
})
def convert_to_snake_case(pascal_or_camel_cased_string):
snake_cased_char_list = []
for char in pascal_or_camel_cased_string:
--fcc-editable-region--
if char.isupper():
pass
--fcc-editable-region--