The print method in Python

Subscribe to my newsletter and never miss my upcoming articles

In this post, we will explore the parameters of the print() function. In Python, the print() function is used to print something on the console.


print("whatever you want to print..")


Consider the below program,

a = [1,2,3,4]
for i in a:

When you run the program the output will be,


By default, Python prints everything in a new line. But in languages like C/C++ in not by default. To customize the output format Python's print() method has some parameters. They are :

  1. end
  2. sep

end parameter

This is used to end a print statement with any character/string. If we want to print the above example horizontally, we can use the end parameter.


a = [1,2,3,4]
for i in a:
  print(i, end=" ")

The output will be

  1 2 3 4

sep parameter

Used to change the separator between the arguments in print(). By default Python uses space as a separator, you can change its character, integer, etc using this parameter.


print( 'a' , 'b' , 'c')

The output will be

a b c

If you want to separate each argument with some symbol, you can use the sep parameter

print( 'a' , 'b' , 'c' , sep = "$")

The output will be

Pinninti Sagar's photo

Nice website brother...😉🔥🔥

Karri Nikhila Bhuvana Chandhrika's photo

Nice website 👌👏👏