Back to Freecodecamp

Step 1

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

latest1.2 KB
Original Source

--description--

In this project, you are going to build a program that takes a camelCase or PascalCase formatted string as input and converts that to a snake_case formatted string using two approaches. First, you'll use a for loop and then list comprehension to achieve the same results. You'll see how list comprehension can make your code more concise.

Start defining a new function named convert_to_snake_case() that accepts a string named pascal_or_camel_cased_string as input. For now, add a pass statement inside the function.

--hints--

You should define a new function named convert_to_snake_case(). Don't forget the colon at the end and use pass to fill the function body.

js
({
  test: () => {
    assert(runPython(`
      import inspect
      inspect.isfunction(convert_to_snake_case)
    `));
  }
})

Your function should take a parameter named pascal_or_camel_cased_string.

js
({
  test: () => {
    assert(runPython(`
      import inspect
      'pascal_or_camel_cased_string' in inspect.signature(convert_to_snake_case).parameters
    `));
  }
})

--seed--

--seed-contents--

py
--fcc-editable-region--

--fcc-editable-region--