How to replace space in a string with \n
Alister
alister.ware at ntlworld.com
Thu Jan 31 04:46:22 EST 2019
On Thu, 31 Jan 2019 10:18:20 +0100, ^Bart wrote:
> Hello everybody! :)
>
> I got a text and I should replace every space with \n without to use
> str.replace,
Why?
> I thought something like this:
>
> text = "The best day of my life!"
>
> space = (' ')
>
> if text.count(' ') in text:
> space=\n
>
> rightText = text-space
>
> print(rightText)
>
> I should have an output like this:
> The best day of my life!
--
There is nothing new except what has been forgotten.
-- Marie Antoinette
More information about the Python-list
mailing list