How do I split the definition of a long string over multiple lines?

You can split a string over multiple lines by using triple quotes, either ''' or """ .

For example:

string = '''This is a long string
that spans multiple lines'''

Or:

string = """This is a long string
that spans multiple lines"""

Watch a course Python - The Practical Guide

You can also use the backslash character ( \ ) at the end of each line to achieve a similar effect:

string = "This is a long string \
that spans multiple lines"

Note that when using the backslash, there should not be any whitespace or characters after it on the same line.