A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://www.geeksforgeeks.org/python/how-to-print-new-line-in-python/ below:

Print new line in Python

Print new line in Python

Last Updated : 02 Jan, 2025

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)

We can also use Multiple \n for Blank Lines.

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

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

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")
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)
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")


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4