Learn Python List Comprehension by Building a Case Converter Program - Step 19

Tell us what’s happening:

Step 19
In Python, a list comprehension is a construct that allows you to generate a new list by applying an expression to each item in an existing iterable and optionally filtering items with a condition. Apart from being briefer, list comprehensions often run faster.

A basic list comprehension consists of an expression followed by a for clause:
Example Code
spam = [i * 2 for i in iterable]
The above uses the variable i to iterate over iterable. Each elements of the resulting list is obtained

Your code so far

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
snake_cased_char_list = [('_' + char.lower()) * 2 for char in pascal_or_camel_cased_string]

Its not working. it is giving the following error and I dnt understand yet
Error: You should turn snake_cased_char_list into a list comprehension that iterates over pascal_or_camel_cased_string.

Please Tell us what’s happening in your own words.

Learning to describe problems is hard, but it is an important part of learning how to code.

Also, the more you say, the more we can help!

a lot of that code should be commented out, reset the step and try again

also do not change the indentation

error is still there

Can you share your code here and link to the step?

I’m not sure what you’re trying to do exactly.

Learn Python List Comprehension by Building a Case Converter Program: Step 19 | freeCodeCamp.org

Try following the simple syntax of the example.

You’ve added an extra if clause that was not asked for. Is it necessary?

if you use char.lower() does it matter if the char is originally uppercase or lowercase or is the result the same? Does it cause an error?