> ## Content Index
> Fetch the complete content index at: https://www.modernlearner.org/llms.txt
> Use this file to discover other available public pages before exploring further.

# Multiline Strings in Python
- URL: https://www.modernlearner.org/multiline-strings-in-python/
- Published: 2020-10-22T22:26:45.000Z
- Updated: 2024-02-28T22:51:28.000Z
- Author: Modern Learner

We covered how to create multiline strings in the Ruby programming language, but what about if you're using Python? Well in Python there are two ways to create a multiline string.

# Triple Quotes for a Multiline Python String

You can use a triple quote or triple double-quote to create a multiline string in Python:

```python
multiline = '''
a string
  with many lines
    in python.
'''

multiline = """
You can use double-quotes
  for a multiline string too,
  and "quotes" within the 'string'.
"""

```

# Brackets to Enclose a Multiline String

The other way is to use a bracket to enclose multiple strings that use single or double quotes:

```python
multiline = (
'first'
'second'
)

multiline = (
  "hello"
  "world"
)

```

**You will need to add a '\\n' at the end of each line to preserve the newlines.** Just like this:

```python
multiline = ("first line\n"
  "second line\n"
)

```