How to write the words one under the other

Viewed 107

When I enter this code, it just seems like this:

Code

But it should be word by word for each line, not letter by letter. I can't solve it, so here is my code:

siir = "Karşında ziya yoksa, sağından ya solundan. Tek bir ışık olsun buluver, kalma yolundan."

print(*siir[0:len(siir)], sep="\n")
2 Answers

To use that approach you must split it into a list of strings first.

print(*siir.split(),sep="\n")

although I prefer

print(siir.replace(" ","\n"))

You can do this:

print(*siir.split(), sep="\n")

And get a list of words.

You do not need to do this: .split(" ") because it is the default.

Related