Categories
Python Answers

How to create a long multi-line string with Python?

Spread the love

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 enclose our string content with ''' or """.

For instance, we write:

s = """ This is a very
        long string if I had the
        energy to type more and more ..."""

or:

s = ''' This is a very
        long string if I had the
        energy to type more and more ...'''

to define the s multi-line string.

Conclusion

To create a long multi-line string with Python, we can enclose our string content with ''' or """.

By John Au-Yeung

Web developer specializing in React, Vue, and front end development.

Leave a Reply

Your email address will not be published. Required fields are marked *