- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to print without newline in Python?
In python the print statement adds a new line character by default. So when we have multiple print statements the output from each of them is printed in multiple lines as you can see in the example below. Our goal is to print them in a single line and use some special parameters to the print function to achieve that.
Normal Print()
The below example prints multiple statements with new lines in each of them.
Example
print("Apple") print("Mango") print("Banana")
Output
Running the above code gives us the following result −
Apple Mango Banana
Using end Parameter
We can use the end parameter to use a specific character at the end of the output from each print statement. In the below example we use "," as special character with the end parameter, which will appear at the end of the output of each print statement. The result will not be printed in multiple lines.
Example
print("Apple" , end ="," ) print("Mango", end =",") print("Banana")
Output
Running the above code gives us the following result −
Apple,Mango,Banana