Build a Pin Extractor - Step 17

Tell us what’s happening:

i have moved everything to new loop yet it says move …

Your code so far


# User Editable Region

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 line_index < len(words):
                secret_code += str(len(words[line_index]))
            else:
                secret_code+="0"    

        return secret_code

# User Editable Region

poems = ["""Stars and the moon
shine in the sky
white and
until the end of the night""",

''''The grass is green\nhere and there\nhoping for rain\nbefore it turns yellow''',
'''There\nonce\nwas\na\ndragon''']

#print(pin_extractor(poems))

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/148.0.0.0 Safari/537.36

Challenge Information:

Build a Pin Extractor - Step 17

GitHub Link: freeCodeCamp/curriculum/challenges/english/blocks/workshop-pin-extractor/68599f0fc7479410b2269742.md at main · freeCodeCamp/freeCodeCamp · GitHub

Hi there,

You were not asked to assign a value to poems.

I suggest resetting this step so you can try again.

Happy coding!

Tell us what’s happening:

i resetted the poem variable yet it shows move function to new loop

Your code so far


# User Editable Region

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

#print(pin_extractor(poems))

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

Challenge Information:

Build a Pin Extractor - Step 17

GitHub Link: freeCodeCamp/curriculum/challenges/english/blocks/workshop-pin-extractor/68599f0fc7479410b2269742.md at main · freeCodeCamp/freeCodeCamp · GitHub

you changed this line, why is that?

it doen not raise an error solve my problem of moving function to loop

what about the return? it says that everything in the function should go in the loop

yes, it does raise an error, the tests do not find the lines they expect and the tests fail.

Tell us what’s happening:

i tried moving return yet same results that move to new loop

Your code so far


# User Editable Region

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

#print(pin_extractor(poems))

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

Challenge Information:

Build a Pin Extractor - Step 17

GitHub Link: freeCodeCamp/curriculum/challenges/english/blocks/workshop-pin-extractor/68599f0fc7479410b2269742.md at main · freeCodeCamp/freeCodeCamp · GitHub

i did not change any line it is as it is yet raising error

It looks like you may have changed the starting code in areas you were not asked to change, which will cause the tests to fail. Please click the reset button to restore the original code and try again.

image


After resetting, only make the changes you were asked to make in the instructions. Don’t make any other changes.

Please do not create duplicate topics for the same challenge/project question(s). If you need more help then respond back to the original topic you created with your follow up questions and/or your updated code and question.

The duplicate topics have been unlisted.

Thank you.