Introduction
Sometimes you want to write more than one line of text at once. This helps you keep your code neat and easy to read.
Jump into concepts and practice - no test required
Sometimes you want to write more than one line of text at once. This helps you keep your code neat and easy to read.
'''This is a multi-line string''' """This is also a multi-line string"""
message = '''Hello, Welcome to Python!''' print(message)
print("""Line one Line two Line three""")
This program stores a short poem in a multi-line string and prints it exactly as written.
poem = '''Roses are red, Violets are blue, Python is fun, And so are you.''' print(poem)
Make sure to use the same type of triple quotes at the start and end.
Indentation inside the triple quotes is preserved, so be careful with spaces.
Use triple quotes to write multiple lines of text easily.
Multi-line strings keep line breaks and spaces as you type them.
This helps when printing or storing long text blocks.
'''This is a\nmulti-line string''' correctly uses triple quotes to write a multi-line string. Other options misuse quotes or syntax.text = '''Hello World Python''' print(text)
text = '''Line 1 Line 2 Line 3' print(text)