Scientific computing list comprehension task

Hi i am stuck on this task

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 by evaluating the expression i * 2 at the current iteration.

In this step, you need to fill the empty list snake_cased_char_list using the list comprehension syntax.

Turn your empty list into a list comprehension that converts each character in pascal_or_camel_cased_string into a lowercase character and prepends an underscore to it (the code you commented out before may help you write the expression). Use char to iterate over pascal_or_camel_cased_string.

i did this but it dint accept
snake_cased_char_list =
snake_cased_char_list = [(‘_’ + char.lower()) if char.isupper() else char for char in pascal_or_camel_cased_string]

i dont know what to do to solve

Welcome to the forum @kpr.shubh

You were not asked to include the if and else statements.
Try removing them.

Happy coding

snake_cased_char_list = [‘_’ + char.lower() for char in pascal_or_camel_cased_string]
This is my code for this step. but still its not passing. Plz guide me here

hi @AniqaAkhtar

If you have a question about a specific challenge as it relates to your written code for that challenge and need some help, click the Help button located on the challenge. This button only appears if you have tried to submit an answer at least three times.

The Help button will create a new topic with all code you have written and include a link to the challenge also. You will still be able to ask any questions in the post before submitting it to the forum.

Thank you.