Use replace ('\n', ' ')
https://stackoverflow.com/questions/47301795/removing-special-characters-from-a-list-of-items-in-python
map(str.rstrip, lines) or in list comprehension form: [l.rstrip() for l in lines]
infile.read().split("\n")
There is a built-in str.splitlines
Yes, just don't used to 😅
btw thanks. I checked again, didn't before notice it's more than split('\n')
Yes… But must include print(infile.read().replace(“\n”, “”)
Yes this works… Thank you!
you're welcome but as @Da_Donut said infile.read().splitlines() is better
Once again, thanks both @musaitbiyerde and @Da_Donut
yes it works... but it returns me as 2D list when I use list comprehension
and it returns me a 1D list when i use strip method
Обсуждают сегодня