Tell us what’s happening:
Hi,
I’ve tried modifying my code several times, but I still keep getting the same error and I can’t move on to the next step.
The error message says:
“You should move the existing body of the function into the new for loop.”
I’ve checked my indentation and structure, and it looks correct to me, but the checker still doesn’t accept my solution.
Could someone please help me understand what I’m doing wrong or what exactly the checker expects here?
Thanks in advance!
Your code so far
# User Editable Region
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 line_index < len(words):
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'
# User Editable Region
# print(pin_extractor(poems))
Your browser information:
User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/147.0.0.0 Safari/537.36
Challenge Information:
Build a Pin Extractor - Step 17