Multiline string

2 snippets across 2 stacks — JavaScript, Python

JSJavaScript

Template Literals

JS · Strings
syntax
`text ${expression} text`
example
const item = "coffee";
const price = 4.5;
console.log(`One ${item} costs $${price.toFixed(2)}.`);

const multiline = `Line one
Line two
Line three`;
console.log(multiline);
output
"One coffee costs $4.50."
"Line one\nLine two\nLine three"

Note Backtick strings support embedded expressions and multiline content without escape characters.

PYPython

Multiline Strings

PY · Strings
syntax
"""text
spanning lines"""
example
query = """
    SELECT name, email
    FROM users
    WHERE active = true
""".strip()
print(query)
output
SELECT name, email
    FROM users
    WHERE active = true

Note Triple-quoted strings preserve all whitespace and newlines. Use textwrap.dedent() or .strip() to control leading/trailing space.