Tutorialspoint.dev

Python | end parameter in print()

By default python’s print() function ends with a newline. A programmer with C/C++ background may wonder how to print without newline.

Python’s print() function comes with a parameter called ‘end’. By default, the value of this parameter is ‘ ’, i.e. the new line character. You can end a print statement with any character/string using this parameter.

# This Python program must be run with
# Python 3 as it won't work with 2.7.
  
# ends the output with a <space> 
print("Welcome to" , end = ' '
print("GeeksforGeeks", end = ' ')

Output :

Welcome to GeeksforGeeks

One more program to demonstrate working of end parameter.

# This Python program must be run with
# Python 3 as it won't work with 2.7.
  
# ends the output with '@'
print("Python" , end = '@'
print("GeeksforGeeks")

Output :

[email protected]

Please write comments if you find anything incorrect, or you want to share more information about the topic discussed above



This article is attributed to GeeksforGeeks.org

tags:

Python

You Might Also Like

leave a comment

code

0 Comments

load comments

Subscribe to Our Newsletter