Skip to content
Advertisement

How to break text into paragraphs (python)

So I’m making a text-based game but when I run my code the text isn’t broken up into paragraphs, there is no space between the first print() command and the one right after it.

I’ve tried breaking up the text by putting huge spaces between the text in one print command but that is inefficient and makes my code look messy and difficult to work in.

if status.lower().strip() == "modest":
    print("#.")
    print("#")
    print("#")
    print("#")
    print("#")
else:
    main()

So what I am trying to do is replicate an HTML command <br> which can add space between two lines of text. Is there any way I can do that?

Advertisement

Answer

Use linebreak command n several times as you wish and I suggest you use triple quotes as follows:

print("""
    First paragraph nn
    Second paragraph nn
    ...
    Last paragraph.
""")
User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement