Wednesday, June 2, 2021

Python Program to Print Output Without a Newline

 

Python Program to Print Output Without a Newline

Using end keyword

# print each statement on a new line
print("Python")
print("is easy to learn.")

# new line
print()

# print both the statements on a single line
print("Python", end=" ")
print("is easy to learn.")

Output

Python
is easy to learn.

Python is easy to learn.

Using the end keyword, you can append a string at the end of the print text. In the above example, we have passed a space with end, which adds a space at the end of the line and concatenates the content of the next print statement.

No comments:

Post a Comment

Paid UDEMY Courses for FREE with Certificate

FREE UDEMY Courses In this article, you will always find the updated list of all Paid UDEMY Courses for FREE with Certificate by using 100% ...