How to print multiple lines in Python
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 ")#orprint(' 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.
Free Resources
Copyright ©2025 Educative, Inc. All rights reserved