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 ‘\n’, 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 :
Python@GeeksforGeeks
This article is contributed by Ankit Bindal. If you like GeeksforGeeks and would like to contribute, you can also write an article and mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please write comments if you find anything incorrect, or you want to share more information about the topic discussed above
Recommended Posts:
- Python PIL | BoxBlur() method
- Python | sympy.ones() method
- Python | sympy.zeros() method
- Python | sympy.eye() method
- How to write an empty function in Python - pass statement?
- Operator Functions in Python | Set 2
- Time Functions in Python | Set-2 (Date Manipulations)
- Send mail from your Gmail account using Python
- Python – The new generation Language
- Print Single and Multiple variable in Python
- Increment and Decrement Operators in Python
- str() vs repr() in Python
- Swap two variables in one line in C/C++, Python, PHP and Java
- Generate all permutation of a set in Python
- Class or Static Variables in Python



