Python Program to Print Output Without a Newline – 2024

Hey guys, in this blog we will see a Python Program to Print Output Without a Newline.

Using end keyword

# print each statement on a new line
print("I love blogs")
print("from machinelearningprojects.net")

# new line
print()

# print both the statements on a single line
print("I love blogs", end=" ")
print("from machinelearningprojects.net")

Output

I love blogs
from machinelearningprojects.net

I love blogs from machinelearningprojects.net
  • First of all, we have printed ‘I love blogs’.
  • In the second line, we have printed ‘from machinelearningprojects.net’.
  • Then we printed an empty line.
  • In the 4th example, we have again printed ‘I love blogs’ but this time we have set the end parameter to ‘ ‘ (space). By default, this is set to ‘\n’ which means a new line. That’s why in the 2 example print statement went into the second line due to the end=’\n’ of the first print statement.
  • The last print statement will come just after the ‘I love blogs’.

Check out our other python programming examples

Leave a Reply

Your email address will not be published. Required fields are marked *