Get Even More Visitors To Your Blog, Upgrade To A Business Listing >>

How to print without new line (Same Line) in Python

In this tutorial, we are going to see “How to print without new line (Same Line) in Python“.  Usually, if you give print statement in python, it will be printed in lines sequentially.  For sample, please find the example below
for i in range(1,31,1):
print(i)

will give you the results from 1 to 30, single number in each new line.  If we want to have all 30 numbers in same line, it is possible to do that in Python.  The simplest idea for that is – adding ‘end’ parameter in print statement.  It will make the output in single line i.e., printing without new line or the same line.  Please find the example below.

for i in range(1,31,1):
print(i, end=”)

Output will be in same line as below:
123456789101112131415161718192021222324252627282930

We can add ‘\t’ if we want tab space in between numbers
for i in range(1,31,1):
print(i, end=’\t’)

Output for the above would be like

1     2     3  and so on.

The post How to print without new line (Same Line) in Python appeared first on Payilagam | Java | .NET | Selenium| PHP | Android | DevOps| Ionic| Best Training in Chennai.



This post first appeared on Best .NET Training Institutes In Chennai, please read the originial post: here

Share the post

How to print without new line (Same Line) in Python

×

Subscribe to Best .net Training Institutes In Chennai

Get updates delivered right to your inbox!

Thank you for your subscription

×