Trusted answers to developer questions
Trusted Answers to Developer Questions

Related Tags

print
python
multiple lines

How to print multiple lines in Python

Educative Answers Team

Implementation

Code 1

To print a single line, we cover our string with single/double quotes and pass it to the print() function:

print(" Hello World ")
#or
print(' Hello Again ')

Code 2

Similarly, using triple quotes enables us to print multiple lines in one statement:

print('''

|==[[[[[]]]]]==||==[[[[[]]]]]==|
|==[[[[[]]]]]==||==[[[[[]]]]]==|
|==[[[[[]]]]]==||==[[[[[]]]]]==|
|==[[[[[]]]]]==||==[[[[[]]]]]==|    
|==[[[[[]]]]]==||==[[[[[]]]]]==|
|==[[[[[]]]]]==||==[[[[[]]]]]==|

''')

Note: the triple quote must be made by three single quotes rather than a single quote and a double quote.

RELATED TAGS

print
python
multiple lines
Copyright ©2022 Educative, Inc. All rights reserved
RELATED COURSES

View all Courses

Keep Exploring