Build a Pin Extractor - Step 14

Tell us what’s happening:

please help, i’m stuck in here, how to make it right & work?

Your code so far

def pin_extractor(poem):
    secret_code = ''
    lines = poem.split('\n')
    for line_index, line in enumerate(lines):
        words = line.split()

# User Editable Region

        secret_code += str(len(words[line_index]))
        if secret_code <> "":
            pass


# User Editable Region

    return secret_code

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

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/146.0.0.0 Safari/537.36

Challenge Information:

Build a Pin Extractor - Step 14

So you are not solving the problem they are requesting you to solve.

Put the line secret_code += str(len(words[line_index])) in an if statement that checks that there are enough words in the words list.

Right now your if statement is well its actually doing nothing and returning this error:

Traceback (most recent call last):
File “main.py”, line 10
if secret_code <> “”:
^^
SyntaxError: invalid syntax

fix your if statement and solve the problem they have asked of you in step 14. I will tell you that you are very close and you only need to have the if statement check if one thing has a longer character length than another then join your secret code to the str(len(words[line_index])) you got this. If you still havent figured it out reply to me and I will try and guide you as best as I can but I cannot give you the correct lines of code. Good luck! let me know if you need more help.

Tell us what’s happening:

please help, i think i’ve follow the instructions with correctly, but not working

Your code so far

def pin_extractor(poem):
    secret_code = ''
    lines = poem.split('\n')
    for line_index, line in enumerate(lines):
        words = line.split()

# User Editable Region

        secret_code += str(len(words[line_index]))
        if secret_code <> "":
            pass


# User Editable Region

    return secret_code

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

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/146.0.0.0 Safari/537.36

Challenge Information:

Build a Pin Extractor - Step 14

Hi @nokyardiyansyah,

I’m seeing this error in the console:


Traceback (most recent call last):
  File "main.py", line 10
    if secret_code <> "":
                   ^^
SyntaxError: invalid syntax

Also, the instruction was to put secret_code += str(len(words[line_index])) inside the if statement.

Happy coding!

I went ahead and combined your posts for you. In the future, just reply to the original thread to add further updates. Do not create duplicate topics for the same challenge/step.