Multi-Line printing in Python

We have already seen the basic use of print function previous article. Now, let’s see how to use print function for multi-line printing. This can easily be done using multiline string i.e. three single quotes ''' Geeksforgeeks ''' .

Let’s see different examples to see the demonstration for the same.

Example #1:

filter_none

edit
close

play_arrow

link
brightness_4
code

# basic example for multi-line printing
print(
'''
=======================================
|                                     |
|                                     |
|          GeeksforGeeks              |
|                                     |
|                                     |
=======================================
'''
    )

chevron_right


Output:

=======================================
|                                     |
|                                     |
|          GeeksforGeeks              |
|                                     |
|                                     |
=======================================

Example #2:

filter_none

edit
close

play_arrow

link
brightness_4
code

# basic example2 for multi-line printing
print(
  '''list.head        second              third 
         |                |                  | 
         |                |                  | 
    +----+------+     +----+------+     +----+------+ 
    | 1  | None |     | 2  | None |     |  3 | None | 
    +----+------+     +----+------+     +----+------+ 
    '''
    )

chevron_right


Output:

list.head        second              third 
         |                |                  | 
         |                |                  | 
    +----+------+     +----+------+     +----+------+ 
    | 1  | None |     | 2  | None |     |  3 | None | 
    +----+------+     +----+------+     +----+------+


My Personal Notes arrow_drop_up

Check out this Author's contributed articles.

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.




Article Tags :
Practice Tags :


Be the First to upvote.


Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.