Build a Pin Extractor - Step 17

Tell us what’s happening:

I do not know what i am doing wrong here. I have tried all forms of indentations.

Your code so far


# User Editable Region

def pin_extractor(poems):
    secret_codes = []
    for poem in poems:
        secret_code = ''
        lines = poem.split('\n')
        for line_index, line in enumerate(lines):
            words = line.split()
            if len(words) > line_index:
                secret_code += str(len(words[line_index]))
            else:
                secret_code += '0'
        secret_codes.append(secret_code)
    return secret_codes

# User Editable Region


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

poem2 = 'The grass is green\nhere and there\nhoping for rain\nbefore it turns yellow'
poem3 = 'There\nonce\nwas\na\ndragon'

# Testing with all three poems in a list
print(pin_extractor([poem1, poem2, poem3]))

Your browser information:

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

Challenge Information:

Build a Pin Extractor - Step 17

Welcome to the forum @AhmedAlSanhoty!

Is this line inside the for loop? Edit: And is this line the same as the starting code? You may need to reset this step and try again.

Were you asked to write this code?

Happy coding!

Yes it was asked of me, and yes the empty ,ist was also asked of me.

I have tried resetting and its not working. By resetting you mean only step 17 yes?

Yes. Reset Step #17 and try again.

When I ask questions like that, I’m trying to guide you to areas where your code has an issue.

This is not the same line of code that was in the starting code. You changed it.

You were not asked to add this in the instructions.

Thank you for the replies. I have restarted the exercise again from step 1 and I finished it completely.

please i have done everything I know is right but i’m getting the error, you should move the existing body of the function into the new for loop. and i have done that over and over again

Welcome to the forum @bellodestiny1992!

Please create your own topic when you have specific questions about your own challenge code. Only respond to another thread when you want to provide help to the original poster of the other thread or have follow up questions concerning other replies given to the original poster.

The easiest way to create a topic for help with your own solution is to click the Help button image located on each challenge. This will automatically import your code in a readable format and pull in the challenge URL while still allowing you to ask any question about the challenge or your code.

Thank you.

Happy coding!

Thank you so much for your timely response.