Pin extractor step 17 - please help

Please could someone help me I would really appreciate it, I can’t find the problem.

def pin_extractor(poems):
    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'
    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'

poems = [poem, poem2, poem3]
pin_extractor(poems)

Hi there,

In the starting code, this line was aligned with the inner for loop.

Happy coding!

That was an easy fix, thank you much appreciated!

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