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

Tell us what’s happening:

I am lost. searched everywhere on how to solve. pls help me figure it out?

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 = []

# User Editable Region

    return snake_cased_char_list=''.join(snake_cased_char_list)

# User Editable Region


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

main()

Your browser information:

User Agent is: Mozilla/5.0 (X11; CrOS x86_64 14541.0.0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/126.0.0.0 Safari/537.36

Challenge Information:

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

Hi @ab02ab02

You have a syntax error.

x

You do not need to assign anything for this step.

Happy coding

ok, I tried again by getting rid of the = since I assumed that meant I assigned something… and deleted the first snake_cased_char_list since I guess it was irrelevant. thank you! sorry, I am such a newbie, hoping it helps the next person if I spell out what I did based on the advice you provided.

2 Likes

The variable snake_cased_char_list is being re-declared within the return statement, which is not valid syntax in Python. To fix this, simply remove the variable name and the = sign.

With this fix, your code will run. :blush:
Let me know if you need more assistance!

This help me. I tried so hard to get it fix on my own but when i finally check here i got it clear from your explanation. Thanks you!