top of page

Python Tutorial

Public·1 member

Python print function

Python print function can be written in different format


Let us example of print method


Example 1: Single argument

print("Hello")

output: Hello


Example 2: Multiple arguments

print("Hello","Codersarts")

output: Hello Codersarts


in python print function you can pass any no of argument or variable

by default all argument will be printed on console with space separated.


in the above print statement "Hello" and "Codersarts" are two arguments. similarly you can write any no of argument with comma separator.


so "Hello" and "Codersarts" will be printed on console with separator space.


Example 3: Multiple arguments with user defined separator


print("Hello","Codersarts",sep=":")

output: Hello:Codersarts

with the help of sep keyword in print you can define your own delimiter.



Example 4: Multiple arguments with end keyword

print("Hello","Welcome to",sep=":")
print("Codersarts")

output: Hello Welcome to

Codersarts

by default print statement end with new line '\n', so to change you own end then you can use end keyword

print("Hello","Welcome to",end=" ") 
print("Codersarts")

output: Hello Welcome to Codersarts


11 Views
bottom of page