Sometimes, we want to create a long multi-line string with Python.
In this article, we’ll look at how to create a long multi-line string with Python.
How to create a long multi-line string with Python?
To create a long multi-line string with Python, we can wrap our string content with 3 single or double quotes.
For instance, we write
s = """ Lorem ipsum dolor sit amet,
consectetur adipiscing elit.
Vivamus id tellus at sem euismod bibendum vitae quis odio.
Aliquam ac convallis risus"""
to create the string s
that spans multiple lines by wrapping its content with 3 double quotes.
Conclusion
To create a long multi-line string with Python, we can wrap our string content with 3 single or double quotes.