In Python, when you use the print function, it prints a new line at the end.
For example:
print "This is some line."
print "This is another line."
Output:
This is some line.
This is another line.
What if you want to avoid the newline and want to print both statements on same line? Well, there are 2 possible solutions.
print "This is some line.",
print "This is another line."
Output:
This is some line. This is another line.
If you are using Python 3 then use the below:
print ("This is some line.", end="")
print ("This is another line.")
import sys
sys.stdout.write("This is some line.")
sys.stdout.write("This is another line.")
Help us improve this content by editing this page on GitHub