I do not know what i am doing wrong here. I have tried all forms of indentations.
Your code so far
# User Editable Region
def pin_extractor(poems):
secret_codes = []
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'
secret_codes.append(secret_code)
return secret_codes
# User Editable Region
poem1 = """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'
# Testing with all three poems in a list
print(pin_extractor([poem1, poem2, poem3]))
Your browser information:
User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/146.0.0.0 Safari/537.36
please i have done everything I know is right but i’m getting the error, you should move the existing body of the function into the new for loop. and i have done that over and over again
Please create your own topic when you have specific questions about your own challenge code. Only respond to another thread when you want to provide help to the original poster of the other thread or have follow up questions concerning other replies given to the original poster.
The easiest way to create a topic for help with your own solution is to click the Help button located on each challenge. This will automatically import your code in a readable format and pull in the challenge URL while still allowing you to ask any question about the challenge or your code.