Computer >> Computer tutorials >  >> Programming >> Python

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


To create multiline strings, instead of using one pair of single/double quotes, we use three pairs. For example,

multiline_str = """
My
multi-line
string
"""
print multiline_str

 This will give the output:

  My
  multi-line
  string

 Note that you cannot interpolate strings using this notation. This notation is also used to define docstrings in Python.