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