Learn Python List Comprehension By Building a Case Converter Program - Step 12

Tell us what’s happening:

Describe your issue in detail here.

Hi team, I can’t go beyond this step. I tried many times.

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


/* User Editable Region */

def main():
    convert_to_snake_case('aLongAndComplexString')
    print(convert_to_snake_case)


/* User Editable Region */

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36 Edg/120.0.0.0

Challenge Information:

Learn Python List Comprehension By Building a Case Converter Program - Step 12

You appear to have created this post without editing the template. Please edit your post to Tell us what’s happening in your own words.

is this prinnting the output of the function?

Even when I print(‘aLongAndComplexString’) I have the sme error:

Sorry, your code does not pass. Don’t give up.

You should call convert_to_snake_case() inside the main() function and pass aLongAndComplexString as input to the function.

When you try to print the following:

It won’t print anything because you’re not declaring the function, and is missing an argument, like this: convert_to_snake_case('This is an example string').

To get the result that you want, you are almost there. Just print out your line above:

1 Like

Here is the whole code:

def main():
    convert_to_snake_case('aLongAndComplexString')
        print(convert_to_snake_case)

It does not pass.

I solved the issue. Thanks

1 Like