Python sep | Join | print parameter Example

Today, We want to share with you python sep.In this post we will show you python \t separator, hear for The ‘sep’ and ‘end’ parameters in Python print statement we will give you demo and example for implement.In this post, we will learn about How To Skip A Line In Python? with an example.

Python | sep parameter in print()

The separator between the arguments to print() function in Python is space by default (softspace feature) , which can be modified or changed and can be made to any types of the character, integer or string as per our needed. The ‘sep’ parameter is used to achieve the same, it is retrive only in python 3.x or later. It is also used for best formatting the results strings.

Examples:

#code for disabling the softspace feature 
print('P','K','P', sep='') 
  
#for formatting a date 
print('08','04','2021', sep='-') 
  
#another example 
print('virat','pakainfo', sep='@') 

Results:

PKP
08-04-2021
virat@pakainfo

The sep parameter when used with end parameter it produces best results. More Basic or Adavance level examples by combining the sep and end parameter.


print('P','K', sep='', end='') 
print('P') 
#n provides new line after printing the year 
print('08','04', sep='-', end='-2021n') 
  
print('virat','kohali', sep='', end='@') 
print('pakainfo') 

Results:

PKP
08-04-2021
viratkohali@pakainfo

Note: Please change the language from Python to Python 3 in the online ide.

and last you can show to your interactive python ide by typing python in your cmd ( windows ) or terminal ( linux )

#import the below module as well as watch what happens 
import antigravity 
#NOTE - it wont work on online ide 

I hope you get an idea about python sep.
I would like to have feedback on my infinityknow.com blog.
Your valuable feedback, question, or comments about this article are always welcome.
If you enjoyed and liked this post, don’t forget to share.

Leave a Comment