Build a Pin Extractor - Step 4

Tell us what’s happening:

Where do I find information about the “split” method and how to use it? As far as I know, there is no mention whatsoever of the split method in the previous chapters.

Your code so far

def pin_extractor(poem):
    secret_code = ''

# User Editable Region

    

# User Editable Region


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

pin_extractor(poem)
lines = 

Your browser information:

User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/18.3.1 Safari/605.1.15

Challenge Information:

Build a Pin Extractor - Step 4

I modified my code based on what I found on internet (frankly, I am wondering what the use is of trying a split method that was not explained previously). Here is my code, I see no comment/error message in the console

def pin_extractor(poem, lines):
    secret_code = ''
  

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

lines = poem.splitlines()
pin_extractor(poem, lines)

CAN YOU PLeaSe HELP ??

you are not asked to add a new parameter to the function, please don’t do that

you are asked to create the lines variable inside the function

here you can find where split is introduced: https://www.freecodecamp.org/learn/python-v9/lecture-introduction-to-python-strings/what-are-some-common-string-methods

I used the split method and syntax and applied in my code. It says SyntaxError: unexpected character after line continuation character. I don’t get it

def pin_extractor(poem):
    secret_code = ''

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

lines = poem.split(\n)

first issue
you can’t write \n like that, you need to pass a string to split, so how can you make \n into a string?
second issue, you must write inside the function

Ok, found it. Thanks

Please be patient and do not bump your threads like this. It’s annoying for everyone to read this.

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