Sep parameter
The separator between the arguments to print() function in Python, its identify by space, by default and it is known as softspace feature, which can be modified and can be made to any character, integer or string as per our choice. The ‘sep’ parameter is used to achieve the same, it is found only in python 3.x or later. It is also used for formatting the output strings.
Lets see some examples related to this :
print
(
'C'
,
'D'
,
sep
=
'')
print
(
'09'
,
'05'
,
'2020'
, sep
=
'-'
)
print
(
'bikki'
,
'codedudle'
, sep
=
'@'
)
the strings will separate with the characters which have used in the 'sep'
parameter.
output :
C D
09-05-2020
bikki@codedudle
We have discussed already about the 'end' parameter in print() function,
when we use this with 'sep' parameter its generate an awesome result.
lets see how :
print
(
'C'
,
sep
=
'
', end='
')
print
(
'D'
)
print
(
'09'
,
'05'
, sep
=
'-'
, end
=
'-2020\n'
)
print
(
'bikki'
,
'shaw'
, sep
=
'
', end='
@')
print
(
'codedudle'
)
output :
CD
09-05-2020
bikkishaw@codedudle
And there is a fun thing for you.
Change your language from python to python 3 in the online ide.
Go to your interactive python ide by typing python in your cmd ( windows ) or terminal ( linux )
import antigravity
#matplotlib
#python 3
#scikit learn
#tkinter
#python training
#python data analysis
#best python tutorial
#python classes near me
#learn python for beginners
#python online training
#django course
#advanced python course
#python course fees
#introduction to data science in python
#free python tutorial
#learn python basics
#python study
|
2 Comments
Antigravity is so nice..
ReplyDeletekeep it up
ReplyDeleteIf you have any doubt, Please let me know.