Build a Pin Extractor - Step 17

Tell us what’s happening

i m stuck for hours now . pls help

code is correct but shows

“You should move the existing body of the function into the new for loop.”

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 len(words) > line_index:
                secret_code += str(len(words[line_index]))
            else:
                secret_code += '0'
    return secret_code      # Unchanged: stays after the new loop


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))


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

Challenge Information:

Build a Pin Extractor - Step 17

When it says the entire part that includes that secret_code variable and the return part. So make sure to move that variable declaration and return portion inside the loop too.

1 Like

i did but not working

could anyone tell me what to put inside for loop actually ?

Everything in the body of the function.

not working i did that , and obvious it is inside that fn body…..clarify more

Please share your updated code. Can’t really be more explicit than this.

here the all required code is inside for loop then why it says error?

I have a question. Why did you write this comment?

i was taking some correct code from chat gpt, , so paste it here …so got that also
but that don’t make any diff in the code whether i remove it .

Do you want to learn to code, or not?

yeah ofc i did code by myself but was not approved so i got a refined from chat gpt to check if it works .

Copy/pasting code from ChatGPT will impair your learning, according to research.

“learning is impaired for students who excessively rely on LLMs to solve practice exercises for them and thus do not invest sufficient own mental effort” https://scale.stanford.edu/ai/repository/ai-meets-classroom-when-does-chatgpt-harm-learning

got it ..from now i wont be using cha gpt .

1 Like

kindly give the hint solution for the code

All of the text indented after the function definition is within the body of the function. Please let me know if you have any questions about that.

its the same i did it but error msg showing to put for loop inside fn which is already there

Please share your updated code.