Intellipaat Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in Python by (16.4k points)

I am experiencing a touch of difficulty attempting to discover a response to this. I might want to understand what the syntax sep="" and \t implies. I have discovered some information about it however I didn't exactly comprehend what the reason for utilizing the syntax was. I'm searching for an explanation of what it does and when/why you would utilize it. 

An illustration of sep='' being used:

print('Property tax: $', format(tax, ',.2f'), sep='')

1 Answer

0 votes
by (26.4k points)
edited by

The sep='' with regards to a function consider sets the named argument sep to an unfilled string. See the print() work; sep is the separator utilized between various qualities when printing. The default is a space (sep=' '), this function call ensures that there is no space between Property charge: $ and the organized tax floating-point value. 

Look at the output of the following three print() calls to see the distinction

>>> print('foo', 'bar')

foo bar

>>> print('foo', 'bar', sep='')

foobar

>>> print('foo', 'bar', sep=' -> ')

foo -> bar

sep argument value changed everything.

Using \t or a space as print seperator will shows the difference

>>> print('eggs', 'ham')

eggs ham

>>> print('eggs', 'ham', sep='\t')

eggs    ham

Interested to learn python in detail? Come and Join the python course.

31k questions

32.8k answers

501 comments

693 users

Browse Categories

...