Python print() Method Tutorial

Python print() method is used to print some data or text to the standard output. The standard output is generally a terminal or a console where text or data is printed. The standard output is also called stdout a shortform. The print() method can be used to print text, characters, string literals, numbers, etc. easily. the print() can be used to show some information to the user or debug the script by the developer.

print() Method Syntax

The print() method is very simple where 5 options are accepted. But generally single option which is an object is used single or more times.

print(OBJECTS, sep=SEPARATOR, end=END, file=FILE, flush=FLUSH)
  • OBJECTS is single or more object which will be printed. The OBJECT can be a string literal, string variable, number, list etc.
  • SEPARATOR is the separator character which will be used to separate if multiple objects are provided. The SEPARATOR is optional.
  • END is the characters added to the end of the printed value. END is /n by default which is end of line.
  • FILE is file object for output.
  • FLUSH is the boolean value True or False to flush instantly or buffer. Default value is False which buffers.

Print Text

The most popular use case for the print() method is printing some text. The text can be specified as string literals inside single or double quotes.

print('This is some text or string literal')

print("This is some text or string literal")

Alternatively, we can use string variables or objects to print console or terminal with the print() method.

name = "ismail"


Multiple strings can be printed with a single print() method like below.


print(name," ",surname)

print(name," baydan")

Print Variable

The print() method can be used to print variables in different types like string, integer, etc.




Print List

The print() method can be used to print a list. List contains multiple items and all of them can be printed with the print() method.

names = ["ismail","ahmet","ali"]


Specify Separator

By default, multiple objects can be printed with print() method, and ‘ ‘ is used as the separator. But we can specify different separators by using the separator option. In the following example, we will use ;as separator.

names = ["ismail","ahmet","ali"]


Change End of Line (EoL)

The print() method puts the end of the line for every executed to the end of the output. This means every print() execution ends with the end of the line or with a new line. But this end characters can be changed with the end option.

name = "ismail"


Leave a Comment