Python - print function end-of-line character

Introduction

By default, print adds an end-of-line character to terminate the output line.

You can avoid the line break altogether by passing an empty string to the end keyword argument.

You can pass a different terminator of your own including a \n character to break the line manually if desired:

Demo

x = 'test' 
y = 99 # from w  w w.jav a 2s  .c o  m
z = ['eggs'] 

print(x, y, z, end='')                        # Suppress line break 
print(x, y, z, end=''); print(x, y, z)        # Two prints, same output line 
print(x, y, z, end='...\n')                   # Custom line end

Result

Related Topic