Problem with Pin Extrator step 17

I have a problem with step 17 in the pin extractor. It keeps saying “You should move the existing body of the function into the new for loop.”

def pin_extractor(poems):
    secret_code = ''
    for poem in poems:
        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'
    return secret_code
poem = """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'

# print(pin_extractor(poem))

What can I do

Did you move all of the code from the function into the loop?

yeah iam petty sure. can’t see where I didn’t do it

Is there code that’s in the function and not in the for loop? What about the first line of the function?

got it to work, had a space in one of my indentions"

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.