Back to Freecodecamp

Step 3

curriculum/challenges/english/blocks/learn-list-comprehension-by-building-a-case-converter-program/657ee28cefc4945568287673.md

latest1.1 KB
Original Source

--description--

With the empty list in place, now you can start iterating through the input string and convert it into snake case.

Inside the function, below the list you just created, add a for loop to iterate through the pascal_or_camel_cased_string. Make sure to name the target variable char. For now, add a pass statement as a placeholder in the loop body.

--hints--

You should write a new for loop with the target variable named char. Don't forget the colon at the end and to use pass to fill the loop body.

js
({
    test: () => {
        const transformedCode = code.replace(/\r/g, "");
        const convert_to_snake_case = __helpers.python.getDef("\n" + transformedCode, "convert_to_snake_case");
        const { function_body } = convert_to_snake_case;

        assert.match(function_body, / +for\s+char\s+in\s+pascal_or_camel_cased_string\s*:\s*pass[\s]*$/);
    }
})

--seed--

--seed-contents--

py
--fcc-editable-region--
def convert_to_snake_case(pascal_or_camel_cased_string):
    snake_cased_char_list = []
--fcc-editable-region--