Python multiline strings: \n versus triple quotes

Python multiline strings: \n versus triple quotes

Want to include a newline in a Python string? Use \n:

s1 = 'abc\ndef'  # 7 characters, including newline

That’s fine for small strings. But for longer ones, use a triple-quoted string:

s2 = """abc
def"""

BTW, the created strings are the same:

print(s1 == s2)  # True!