I don’t know what to do, i’m on the step 19 and the console is still saying " The function should return secret_codes at the end."
i tried everything, I tried the code on Google Collab and realized that I would have to specify a poems variable with the list of poems for it to work.
For Google Collab, print(pin_extractor([poem, poem2, poem3])) is also an error.
It should be written without square brackets. However, following the instructions in the exercise, I continue to get this error saying that I should return secret_codes. When I did that, and I think with the correct indentation too.
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'
def pin_extractor(poem, poem2, poem3):
secret_codes = []
poems = [poem, poem2, poem3]
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
print(pin_extractor([poem, poem2, poem3]))
