Python Programs | IT Developer
IT Developer

Python Programs



Share with a Friend

Print a multi-line quote using triple quotes - Python Program

To print a multi-line quote using triple quotes in Python, enclose the text within three single quotes (''') or three double quotes (""").

Type 1 Program

# Uses triple quotes to print multiple lines in one print statement print("""Albert Einstein once said: "Imagination is more important than knowledge. Knowledge is limited. Imagination encircles the world." """) # Using triple single quotes multi_line_quote_single = '''Albert Einstein once said: "Imagination is more important than knowledge. Knowledge is limited. Imagination encircles the world." ''' print(multi_line_quote_single)

Output

 
OUTPUT :
Albert Einstein once said:
"Imagination is more important than knowledge.
Knowledge is limited. Imagination encircles the world."

Albert Einstein once said:
"Imagination is more important than knowledge.
Knowledge is limited. Imagination encircles the world." 

Type 2 Program

# Using triple double quotes multi_line_quote_double = """This is a multi-line quote. It can span across several lines and preserve the line breaks and indentation exactly as typed within the triple quotes.""" print(multi_line_quote_double) # Using triple single quotes multi_line_quote_single = '''Another example of a multi-line quote. You can use either single or double triple quotes. Both work the same way for creating multi-line strings.''' print(multi_line_quote_single)

Output

 
OUTPUT :
This is a multi-line quote.
It can span across several lines
and preserve the line breaks and indentation
exactly as typed within the triple quotes.
Another example of a multi-line quote.
You can use either single or double triple quotes.
Both work the same way for creating multi-line strings.