What does print(... sep='', '\t' ) mean? What does print(... sep='', '\t' ) mean? python python

What does print(... sep='', '\t' ) mean?


sep='' in the context of a function call sets the named argument sep to an empty string. See the print() 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 between Property tax: $ and the formatted tax floating point value.

Compare the output of the following three print() calls to see the difference

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

All 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:

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


sep='' ignore whiteSpace.see the code to understand.Without sep=''

from itertools import permutationss,k = input().split()for i in list(permutations(sorted(s), int(k))):    print(*i)

output:

HACK 2A CA HA KC AC HC KH AH CH KK AK CK H

using sep=''The code and output.

from itertools import permutationss,k = input().split()for i in list(permutations(sorted(s), int(k))):    print(*i,sep='')

output:

HACK 2ACAHAKCACHCKHAHCHKKAKCKH


sep='\t' is often used for Tab-delimited file.