

- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Multi-Line printing in Python
We have usually seen the print command in python printing one line of output. But if we have multiple lines to print, then in this approach multiple print commands need to be written. This can be avoided by using another technique involving the three single quotes as seen below.
Example
print(''' Motivational Quote :\n Sometimes later becomes never, Do it now. Great things never come from comfort zones. The harder you work for something, the greater you'll feel when you achieve it. ''')
Running the above code gives us the following result:
Motivational Quote : Sometimes later becomes never, Do it now. Great things never come from comfort zones. The harder you work for something, the greater you'll feel when you achieve it.
We can use multiline printing to produce nicely formatted text also as seen below.
Example
print(''' =========================================== || || || WORK || || HARD || || || || || || || =========================================== ''')
Running the above code gives us the following result:
============================= || || || WORK || || HARD || || || || || || || =============================
- Related Questions & Answers
- Multi-Line Statements in Python
- Java multi-line comments
- How to execute Python multi-line statements in the one-line at command-line?
- How do we write Multi-Line Statements in Python?
- How to create a long multi-line string in Python?
- How to put multi-line comments inside a Python dict()?
- How to write multi-line comment in Java?
- How to write multi-line comments in C#?
- How to style multi-line conditions in 'if' statements in Python?
- How to comment each condition in a multi-line if statement in Python?
- Printing to the Screen in Python
- What is the difference between single-line and multi-line comments in JavaScript?
- How do we use multi-line comments in JavaScript?
- Array Indexing and Printing in Python (pyCharm)
- How to avoid printing newline in Python?
Advertisements