Build a Pin Extractor - Step 12

Tell us what’s happening:

my code has an error but i tried looking the grammar, spacing and indentation but still not working.

Your code so far


# User Editable Region

def pin_extractor(poem):
    secret_code = ""
    lines = poem.split("\n")

    for line_index, line in enumerate(lines):
        words = line.split()
        if line_index < len(words):
            secret_code += str(len(words[line_index]))

    return secret_code

# 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/147.0.0.0 Safari/537.36

Challenge Information:

Build a Pin Extractor - Step 12

Github Link: freeCodeCamp/curriculum/challenges/english/blocks/workshop-pin-extractor/6859290fc8e07e6b2a8d8523.md at main · freeCodeCamp/freeCodeCamp · GitHub

Welcome to the forum @hedrienem!

Please reset this step and try again. It looks like you added a line of code that was not in the starting code:

Happy coding!

After I removed the code it still doesn’t work, and I’m checking for grammatical errors and spacing there’s nothing. thanks for feedback tho!

Did you reset the step?

Yeah and it didn’t (I’m js a beginner sorry :pensive_face:)

Can you post your code, please, rather than a screenshot:


When you enter a code block into a forum post, please precede it with three backticks to make it easier to read.

You can also use the “preformatted text” tool in the editor (</>) to add the backticks.

See this post to find the backtick on your keyboard.
Note: Backticks (`) are not single quotes (').

def pin_extractor(poem):
    secret_code = ''
    lines = poem.split('\n')
    for line_index, line in enumerate(lines):

        secret_code += str(len(words[line_index]))
    return secret_code
    


poem = """Stars and the moon
shine in the sky
white and bright
until the end of the night"""

pin_extractor(poem)

thanks for the help, i solved the problem thank you.