How to replace space in a string with \n

Peter Otten __peter__ at web.de
Thu Jan 31 05:13:10 EST 2019


^Bart wrote:

>> Why?
> 
> It's a school test, now we should use just what we studied, if than,
> else, sequences, etc.!
> 
> ^Bart

Hint: you can iterate over the characters of a string

>>> for c in "hello":
...     print(c)
... 
h
e
l
l
o







More information about the Python-list mailing list