long_string = """ This is a long multi-line string that can contain multiple lines """
In Python, there are several ways to create a long multi-line string. One common method is to use triple quotes (either single or double) to create a string that can span multiple lines as seen in the code above.
Another way to create a long multi-line string is to use the line continuation character () at the end of each line. Here's an example:
long_string = "This is a long " + \
"multi-line string " + \
"that can contain " + \
"multiple lines"
long_string = f"This is a long \ multi-line string \ that can contain \ multiple lines"
long_string = (
"This is a long "
"multi-line string "
"that can contain "
"multiple lines"
)
long_string = [ "This is a long ", "multi-line string ", "that can contain ", "multiple lines"]
Python Mega Course: Learn Python in 60 Days, Build 20 Apps
Learn Python on Udemy completely in 60 days or less by building 20 real-world applications from web development to data science.
