TECHIES WORLD

For Techs.... Techniques.... Technologies....

CpanelLinuxPython

How to create multi-line string in Python

Usually all the variables having single line of strings and if it have multiple lines, everything will break.

Python have a way to create a long multi-line string.

We can use single quotes, 3 of them at start and 3 of them at end to specify the string.

Once example is given below.

s = """ this is a 
    string having
    multiple lines"""

Here the multi-line string will be treated as ) and treated like any other strings.

That's all…

Leave a Reply