# Build a Pin Extractor - Step 17

**URL:** <https://forum.freecodecamp.org/t/build-a-pin-extractor-step-17/778532>\
**Category:** Curriculum Help\
**Tags:** python\
**Created:** [February 13, 2026, 4:43pm UTC](https://forum.freecodecamp.org/t/build-a-pin-extractor-step-17/778532 "2026-02-13T16:43:46Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![TeaCodes](https://avatars.discourse-cdn.com/v4/letter/t/c37758/32.png) [@TeaCodes](https://forum.freecodecamp.org/u/TeaCodes)\
**Post date:** [February 13, 2026, 4:43pm UTC](https://forum.freecodecamp.org/t/build-a-pin-extractor-step-17/778532/1 "2026-02-13T16:43:46Z")

</div>

### Tell us what’s happening:

At wit’s end what am I missing? Is the existing body of the function not in the for loop? I’ve reset this so many times and can’t figure it out. I’ve played with the indentation and still get the same error.

Error: You should move the existing body of the function into the new for loop.

### Your code so far

```py

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

    return secret_code

# User Editable Region

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

```

### Your browser information:

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

### Challenge Information:

Build a Pin Extractor - Step 17

> **[freeCodeCamp.org](https://www.freecodecamp.org/learn/python-v9/workshop-pin-extractor/step-17)**
>
> Learn to Code — For Free

---

<div class="post-metadata">

**Author:** ![ILM](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/ilm/32/363239_2.png) [@ILM](https://forum.freecodecamp.org/u/ILM)\
**Post date:** [February 13, 2026, 4:44pm UTC](https://forum.freecodecamp.org/t/build-a-pin-extractor-step-17/778532/2 "2026-02-13T16:44:26Z")

</div>

> [@TeaCodes](#):
>
> ` return secret_code`

is this inside the loop?

---

<div class="post-metadata">

**Author:** ![TeaCodes](https://avatars.discourse-cdn.com/v4/letter/t/c37758/32.png) [@TeaCodes](https://forum.freecodecamp.org/u/TeaCodes)\
**Post date:** [February 13, 2026, 4:46pm UTC](https://forum.freecodecamp.org/t/build-a-pin-extractor-step-17/778532/3 "2026-02-13T16:46:24Z")

</div>

I believe so. I have tried all different ways of indenting it and still get the same error.

---

<div class="post-metadata">

**Author:** ![ILM](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/ilm/32/363239_2.png) [@ILM](https://forum.freecodecamp.org/u/ILM)\
**Post date:** [February 13, 2026, 4:49pm UTC](https://forum.freecodecamp.org/t/build-a-pin-extractor-step-17/778532/4 "2026-02-13T16:49:42Z")

</div>

notice how the `for` and the `return` are on the same column, that means that the `return` is not inside the loop

---

<div class="post-metadata">

**Author:** ![TeaCodes](https://avatars.discourse-cdn.com/v4/letter/t/c37758/32.png) [@TeaCodes](https://forum.freecodecamp.org/u/TeaCodes)\
**Post date:** [February 13, 2026, 4:50pm UTC](https://forum.freecodecamp.org/t/build-a-pin-extractor-step-17/778532/5 "2026-02-13T16:50:40Z")

</div>

Well, I indented it and still get the same error.

```auto
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

```

If I indent it again or another time I still get the same error.

---

<div class="post-metadata">

**Author:** ![ILM](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/ilm/32/363239_2.png) [@ILM](https://forum.freecodecamp.org/u/ILM)\
**Post date:** [February 13, 2026, 4:52pm UTC](https://forum.freecodecamp.org/t/build-a-pin-extractor-step-17/778532/6 "2026-02-13T16:52:17Z")

</div>

> [@TeaCodes](#):
>
> ```auto
> 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'
> 
> ```

this is not correct, the loop on `enumarate(lines)` should have more things inside

if you can’t figure it out reset the step and try again

---

<div class="post-metadata">

**Author:** ![TeaCodes](https://avatars.discourse-cdn.com/v4/letter/t/c37758/32.png) [@TeaCodes](https://forum.freecodecamp.org/u/TeaCodes)\
**Post date:** [February 13, 2026, 4:57pm UTC](https://forum.freecodecamp.org/t/build-a-pin-extractor-step-17/778532/7 "2026-02-13T16:57:04Z")

</div>

I’ve reset the step a million times. that line never changes and the instructions don’t say to change anything there. Do i go back a step? did i miss something?

---

<div class="post-metadata">

**Author:** ![ILM](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/ilm/32/363239_2.png) [@ILM](https://forum.freecodecamp.org/u/ILM)\
**Post date:** [February 13, 2026, 5:00pm UTC](https://forum.freecodecamp.org/t/build-a-pin-extractor-step-17/778532/8 "2026-02-13T17:00:34Z")

</div>

what do you mean the line never changes?

starting code is

```py
def pin_extractor(poem):

    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

```

don’t you get this when you reset?

notice how there are things inside the loop, like the if/else

---

<div class="post-metadata">

**Author:** ![TeaCodes](https://avatars.discourse-cdn.com/v4/letter/t/c37758/32.png) [@TeaCodes](https://forum.freecodecamp.org/u/TeaCodes)\
**Post date:** [February 13, 2026, 5:03pm UTC](https://forum.freecodecamp.org/t/build-a-pin-extractor-step-17/778532/9 "2026-02-13T17:03:15Z")

</div>

I understood I needed more code from your post. It turns out it was indentation. I went line by line and checked it until it worked. Thanks.

---

<div class="post-metadata">

**Author:** ![dhess](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/dhess/32/406235_2.png) [@dhess](https://forum.freecodecamp.org/u/dhess)\
**Post date:** [February 13, 2026, 5:17pm UTC](https://forum.freecodecamp.org/t/build-a-pin-extractor-step-17/778532/10 "2026-02-13T17:17:06Z")

</div>

In the future, you can click the reset button to restore the original code.

![image](https://global.discourse-cdn.com/freecodecamp/optimized/4X/a/a/7/aa72a76c651bc9854d2f067de5f3a6fca20da9fb_2_690x46.png)

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/freecodecamp/original/3X/e/1/e1c433102e34b46dfaa3e15d13ab9a514b127078.svg) [@system](https://forum.freecodecamp.org/u/system)\
**Post date:** [March 13, 2026, 5:17pm UTC](https://forum.freecodecamp.org/t/build-a-pin-extractor-step-17/778532/11 "2026-03-13T17:17:23Z")

</div>

Closed on March 13, 2026, 5:17pm UTC

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