Tutorials  Articles  Notifications  Login  Signup


DG

Dhirendra Gupta

Student at BIT Mesra July 31, 2020, 12:13 p.m. ⋅ 1419 views

Python end parameter in print()


print() function in python prints a new line in the end by default. Sometimes we might don't want this behaviour, we may want to print nothing, or an space or maybe some other character. For things like this, we have end parameter in python.

end parameter in python print() function is used to specify the end character to be printed after the given string has been printed.

Have a look at examples.

# ends the output with a <space> 

print("Hello" , end = ' ') 
print("World", end = ' ') 

#Outputs Hello World


print("Hello" , end = '_') 
print("World")


#Outputs Hello_World

 

If we don't specify any end parameter with print() function, then by default, it's a new line character i.e '\n'.

print("Hello")
print("World")

Outputs

Hello
World

 



HackerFriend Logo

Join the community of 1 Lakh+ Developers

Create a free account and get access to tutorials, jobs, hackathons, developer events and neatly written articles.


Create a free account