How to write multi line string?
How to write multi line string?
String typing
Question is closed for new answers.
Abhishek Verma Selected answer as best April 6, 2023
In Python, you can create a multi-line string by enclosing the text in triple quotes, either single quotes ”’ or double quotes “””.
Here is an example of a multi-line string using triple double quotes:
multi_line_string = “””This is a multi-line string.
It can span multiple lines and contain
line breaks and other special characters.”””
In this example, the text is enclosed in triple double quotes and contains three lines of text. You can also use triple single quotes ”’ to achieve the same result.
Multi-line strings are useful for creating blocks of text, such as documentation, emails, or HTML templates. They preserve the original formatting and line breaks, making it easier to read and maintain the text.
Abhishek Verma Selected answer as best April 6, 2023