Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in Python by (50.2k points)

Can anyone tell me how to print in the same line in Python?

1 Answer

0 votes
by (108k points)

If you are using Python 2.x, then you can use a comma to print the statement in the same line.

print "Hey Guys!",

print "This is How we print on the same line."

The output:

Hey Guys! This is How we print on the same line.

And if you are using Python 3.x , then you can use the below code:

for i in range(10):

    print(i, end="<separator>") # <separator> = \n, <space>

The output for the above code snippet would be (when <separator> = " "):

0 1 2 3 4 5 6 7 8 9

If you are looking for an online course to learn Python, I recommend this Python Certification program by Intellipaat.

Related questions

0 votes
1 answer
0 votes
1 answer
0 votes
1 answer
asked Sep 27, 2019 in Python by Sammy (47.6k points)

Browse Categories

...