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

Tell us what’s happening:

Unsure why it will not let me proceed. I have tried commenting out all lines using a # character for single line comments , have tried the “”“” multiple line comments and even cut the lines out completely.

I must be missing something really dumb/obvious!

Your code so far


/* User Editable Region */

def convert_to_snake_case(pascal_or_camel_cased_string):
    pass
    """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('_')"""

def main():

/* User Editable Region */

    print(convert_to_snake_case('aLongAndComplexString'))

if __name__ == '__main__':
    main()

Your browser information:

User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36

Challenge Information:

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

Hello. Here is how you comment out a line of code.

# This is a comment
print("The line above never gets prints");

With that information, how would you comment out those lines of code?

Happy learning. :slight_smile:

yes, I tried commenting out each line using a # symbol and it still doesn\t pass

def convert_to_snake_case(pascal_or_camel_cased_string):
    pass
    # 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('_')

Hello MrAndy,

Is that your whole code in your last reply? It’s missing one of the lines of the original code.

1 Like

Hello! @MrAndyStorey

In the last code you’ve provided, did you miss to comment out the return statement line…? like @HungryBee mentioned…

Try commenting those 10 lines using the # symbol individually including the return statement.

Happy Coding :grinning:

Yes, turns out that to pass the test, you need to have exactly ten lines commented out.
I had changed the return value to return pass and it was still being executed.

Thanks for your help.

1 Like

Tell us what’s happening:

I thought I hade everything correct, especially after reading this thread, but I still get a messsage telling me: " Sorry, your code does not pass. Keep trying.

You should comment out all the 10 lines of code inside the convert_to_snake_case() function and nothing else. Add pass to fill temporarily the function body and avoid an error."

I tried the code below and I also tried to put the pass on line 2 instead of line 13
Tried to delete line 11 (the empty line) not because it should matter, but because I wanted to exhaust every idea I had before turning to you.
Any hints on where I should start looking in my code?

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
    pass
def main():
    print(convert_to_snake_case('aLongAndComplexString'))

if __name__ == '__main__':
    main()

Your browser information:

User Agent is: Chrome/120.0.0.0

Challenge Information:

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

Figured out what went wrong.
If anyone else has the same problem as I had with my code above.
Here’s a hint, it matters where you put the pound signs (#)

I’ve been struggling with this strep in many attempts, but I’ve managed to pass it. Thanks.

1 Like

Figured out what the problem was, the python style guide PEP 8 recommends the use of a space after # while writing inline comments.