The following code:
str = 'Welcome\nto\nPythonExamples\nWelcome\nto\nPythonExamples'
chunks = str.split('\n')
print(chunks)
Correctly prints out:
['Welcome', 'to', 'PythonExamples', 'Welcome', 'to', 'PythonExamples']
I want to split the string into strings that start with 'Welcome\n' so I have tried the following:
str = 'Welcome\nto\nPythonExamples\nWelcome\nto\nPythonExamples'
chunks = str.split('Welcome\n')
print(chunks)
But this prints out:
['', 'to\nPythonExamples\n', 'to\nPythonExamples']
Notice how the first entry is empty. How can I split it up correctly so that the output is?
['to\nPythonExamples\n', 'to\nPythonExamples']