29th Dec 2019, 4:19 PM
Pattern
Pattern - avatar
2 odpowiedzi
+ 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 "."
29th Dec 2019, 4:58 PM
Lothar
Lothar - avatar