In Python, in order to print out text in the console, you can use the print() function. But by default, the print() will add a new line character (based on the OS \n, \r, or \r\n) at the end of the text that it printed out.
If you do not want to print text with a new line character at the end, you can use the end parameter of the print() function.
Example:print("I want to ",end='')
print("continue printing ",end='')
print("on the same line ",end='')
print("using Python print() ",end='')
Output on the same line as expected:
I want to continue printing on the same line using Python print()

More on the "end parameter"
-
The end parameter is used to specify the character or characters that should be printed at the end of the printed text using the print() function.
-
By default end parameter is set to a newline character i.e. \n
-
So when you use the default print() function in python, it always adds a newline character at the end of the text.
-
If you wish to change it to any other character, you can simply use the parameter end= followed by a character.
-
Let's have some fun!
In the below example, we have replaced the end parameter with an emoji and a new line.
print("Hello ",end='😀\n')
print("How are you? ",end='😀\n')
Output:
Hello 😀
How are you? 😀
Facing issues? Have Questions? Post them here! I am happy to answer!
- Python: Convert Date to DateTime
- How to sort a List using Lambda in Python
- Python matplotlib segmentation fault: 11 macOS Big Sur
- What is Terminal Velocity and its Formula? How to calculate it programmatically?
- How to install Python 3.11 on Mac
- How to flatten a nested list in Python
- Python: Pandas Merge DataFrames on Index Example
- How to Run all Cells at Once Jupyter Notebook
- Python - Convert float to String
- How to add borders to tkinter label text
- How to Exit a Loop in Python Code
- [Python] Fix: ValueError: All arrays must be of the same length
- Sorting an array using Bubble Sort in Python Programming
- How to Unzip a file using Python
- Python: Merge DataFrames Pandas Outer Join Example
- Change label (text) color in tkinter
- Convert Float to String in Python
- Fix: fatal error: No such file or directory compilation terminated
- Python: Access index/counter of a for loop iteration
- Import Other Python Files Examples
- How to install Anaconda on Mac (M1/M2 Mac)
- Python Regular Expression to Find All Matches in List
- How to Read a binary File with Python
- How to disable warnings while Python file execution
- Know current Python Version
- Java 8 Predicate Functional Interface Examples - Java
- Maven Eclipse (M2e) No archetypes currently available - Java
- Android Studio setup was canceled - How to resume - Android-Studio
- How to download Microsoft Visual Studio for M1/M2 Mac - MacOS
- Fix: Error: Cannot find module /node-examples/init - JavaScript
- How to retrieve all SharePoint Online List Items using Rest API - SharePoint
- Parse XML file in Java using DOM Parser - Java
- Fix: java.lang.UnsupportedOperationException Java Collections (List, Set, Map) - Java