Home > Software engineering >  How to write the words one under the other
How to write the words one under the other

Time:12-17

So 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")

Hope you guys can help me.

CodePudding user response:

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.

CodePudding user response:

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"))
  • Related