How to replace space in a string with \n

Antoon Pardon antoon.pardon at vub.be
Thu Jan 31 05:58:18 EST 2019


On 31/01/19 11:47, ^Bart wrote:
>>    . A correct answer to the exercise would be:
>>
>> |You cannot replace a space with \n in a string,
>> |because strings are immutable in Python.
>
> Yes, I thought in a wrong way! :)
>
Well maybe you can turn the string into a list of characters. Then
replace the spaces with newlines and finaly turn the list into a string
again. -- Antoon.




More information about the Python-list mailing list