0
Why do I get EOF?
This is the code https://code.sololearn.com/cMcq4cZn1I4I/?ref=app
2 Antworten
+ 5
As swim already mentioned, each line of text is terminated with a newline sequence "\n". To get a workaround, you may put text as one long string together without newline, or you may use a triple quote (instead of double quote) around your text as it is.
Then you can use the following code:
lst = text.split(".")
print(lst)
for val,i in enumerate(lst):
lst[val]=i.strip()
print(lst)
The code removes the newline sequence (that is still present) using strip() method.
There was also a typo in text.spli(...), and I set separator to "."