Open In App

Print new line in Python

Last Updated : 02 Jan, 2025
Comments
Improve
Suggest changes
Like Article
Like
Report

In this article, we will explore various methods to print new lines in the code. Python provides us with a set of characters that performs a specific operation in the code. One such character is the new line character "\n" which inserts a new line.

Python
a = "Geeks\nfor\nGeeks"
print(a)

Output
Geeks
for
Geeks

We can also use Multiple \n for Blank Lines.

Python
a = "Geeks\n\nfor\n\n\nGeeks"
print(a)

Output
Geeks

for


Geeks

There are various other methods to print new line in Python.

Using Empty print() Statements

The basic way to print multiple new lines is by using an extra print statement without any arguments. Each print statement will add a new line.

Python
print("Geeks")

# inserting a single new line
print()	

print("for")

# inserting 2 new lines
print()	

print()
print("Geeks")

Output
Geeks

for


Geeks

Using Triple Quotes for Multiline String

In Python, we can add multiline string by using the triple quotes """ or '''. Whatever is written inside these quotes, is printed as it is.

Python
a = """Hey
I 
am 
Geek"""
print(a)

Output
Hey
I 
am 
Geek

Using end Parameter in print()

The print() function's end parameter can control what is printed at the end of the line. Setting it to \n ensures a new line:

Python
print("Geeks", end="\n")
print("for", end="\n")
print("Geeks")

Output
Geeks
for
Geeks

Next Article
Article Tags :
Practice Tags :

Similar Reads