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

I have been stuck on this for longer than I care to admit. Idk why my brainfart is lasting this long but I have no idea what else to try for finishing this step…

The task at hand is as follows:

Step 12

Inside the main() function, replace pass with a convert_to_snake_case() call. Pass the string aLongAndComplexString as input to the function and print out the output using the print() function.

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; rv:121.0) Gecko/20100101 Firefox/121.0

Challenge Information:

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

hello @Shaitan ;

your function convert_to_snake_case
return clean_snake_cased_string

print out the output using the print() function.

you entering the function in print() call to get ouput.

may i know more specific ?. I need more explaination
Thank You

Found it.
so it just
Mod edit: removed

Idk why that was so hard for me. Any way you or someone could break down the prompt " Inside the main() function, replace pass with a convert_to_snake_case() call. Pass the string aLongAndComplexString as input to the function and print out the output using the print() function." to make me understand why that is the answer?

It is great that you solved the challenge, but instead of posting your full working solution, it is best to stay focused on answering the original poster’s question(s) and help guide them with hints and suggestions to solve their own issues with the challenge.

We are trying to cut back on the number of spoiler solutions found on the forum and instead focus on helping other campers with their questions and definitely not posting full working solutions.

Hello Shaitan,

I’ll give it a go. So we start with just a normal function declaration:

def main():
    pass

We solve it using the following steps, one at a time:

  • Inside the main() function, replace pass with a convert_to_snake_case() call.

As the question says, we can just literally remove pass, and writeconvert_to_snake_case()

  • Pass the string aLongAndComplexString as input to the function.

So to input anything to a function you just put it between the round brackets of the function. as an example: my_function("Input String"). This would add “Input String” into my_function.
Now we do the same thing with the string 'aLongAndComplexString' in the convert_to_snake_case() function we just wrote in the first step.

  • Print out the output using the print() function.

For this step we just put all of the above inside the print() function. So everything we just wrote above go inside the curly brackets () after print so it will output the resule in the console.

3 Likes

Hi, this was my problem as well today, fortunately, I was able to solve it by checking my code again and again. I tried to check the answer here but my code seemed to be all right so I carefully checked it and found out that I missed quotation marks for the string.

1 Like

lol thanks! been staring at my code for the past hour trying to figure out where I had made a mistake…

2 Likes