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.