Build a Pin Extractor - Step 17

Tell us what’s happening:

Step17- How to embed my function content in a for loop?

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 line_index < len(words):
            secret_code += str(len(words[line_index]))
        else:
            secret_code += '0'

    secret_codes.append(secret_code)

return secret_codes

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 line_index < len(words):
                secret_code += str(len(words[line_index]))
            else:
                secret_code += '0'

        secret_codes.append(secret_code)

    return secret_codes

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

Challenge Information:

Build a Pin Extractor - Step 17

Hi.

You are asked to create a for loop around ‘all’ the current content of the function? Have you done this?

You have also changed the seed code in places when you weren’t asked to. I suggest you reset the step and do again without changing the seed code in the existing function content.