Python | final parameter in print ()

Python Methods and Functions

The Python print () function comes with an end parameter. The default value for this parameter is "/ n", which is a newline character. You can terminate the print statement with any character / line using this parameter.

# This Python program must be run with
# Python 3 as it won't work with 2.7.

 
# ends the output with & lt; with a space & gt;

print ( "Welcome to" , end = ''

print ( "GeeksforGeeks" , end = ' ' )

Exit od:

 Welcome to Python.Engineering 

Another program to demonstrate how the final parameter works.

# This program is Python must be run with
# Python 3 as it won't work with 2.7.

  
# ends output with & # 39; @ & # 39;

print ( " Python " , end = '@'

print ( "GeeksforGeeks" )

Output:

 Python @ Python.Engineering 

This article contributed by Ankit Bindal . If you like Python.Engineering and would like to contribute, you can also write an article and mail it to [email protected] See your article appearing on the Python.Engineering homepage and help other geeks.

Please post comments if you find anything wrong or if you'd like to share more information on the topic under discussion





Tutorials