Build a Pin Extractor - Step 8

Tell us what’s happening:

I have done everything I can think of to get my code to pass yet I keep getting the message “You should have print(words[line_index]) at the end of the loop.” Please help!

def pin_extractor(poem):
    secret_code = ''
    lines = poem.split('\n')
    for line_index, line in enumerate(lines):
        print(line_index, line)
        words = line.split()
    if 0 <= line_index < len(words):
        print(words[line_index]) 
    

Your code so far

def pin_extractor(poem):
    secret_code = ''
    lines = poem.split('\n')
    for line_index, line in enumerate(lines):
        print(line_index, line)
        words = line.split()
# User Editable Region
    if 0 <= line_index < len(words):
# User Editable Region
        print(words[line_index]) 
    

poem = """Stars and the moon
shine in the sky
white and bright
until the end of the night"""

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/150.0.0.0 Safari/537.36 Edg/150.0.0.0

Challenge Information:

Build a Pin Extractor - Step 8

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

check indentation, are you sure this is inside the loop?

also why have you added this if? where is this asked for?

Thank you! I have been staring at this for two days and that fixed it.