I am having a bit of trouble trying to find an answer to this. I would like to know what the syntax sep=""
and \t
means. I have found some informaion about it but I didn't quite understand what the purpose of using the syntax was. I'm looking for an explanation of what it does and when / why you would use it.
An example of sep=''
being used:
print('Property tax: $', format(tax, ',.2f'), sep='')
sep=''
in the context of a function call sets the named argumentsep
to an empty string. See theprint()
function;sep
is the separator used between multiple values when printing. The default is a space (sep=' '
), this function call makes sure that there is no space betweenProperty tax: $
and the formattedtax
floating point value.Compare the output of the following three
print()
calls to see the differenceAll that changed is the
sep
argument value.\t
in a string literal is an escape sequence for tab character, horizontal whitespace, ASCII codepoint 9.\t
is easier to read and type than the actual tab character. See the table of recognized escape sequences for string literals.Using a space or a
\t
tab as a print separator shows the difference:sep=''
ignore whiteSpace. see the code to understand.Withoutsep=''
output:
using
sep=''
The code and output.output: