[Solved] What is the point of the sep=”” at the end?


The default value for sep is a space. By setting it to an empty value you print without spaces between the 3 inputs.

You could easily have tried this without the sep argument to see the difference:

>>> print("There are <", 2**32, "> possibilities!", sep="")
There are <4294967296> possibilities!
>>> print("There are <", 2**32, "> possibilities!")
There are < 4294967296 > possibilities!

Note the spaces between the <, the outcome of the 2**32 expression and the >.

The point then is to control how print() outputs the given arguments, something that was not possible in Python 2 where print is a statement.

Perhaps a different example would illustrate this better:

>>> sample = ['foo', 42, 'bar', 81.0]
>>> print(*sample, sep='\n')
foo
42
bar
81.0

By setting the separator to a newline character I made print() write all arguments out on separate lines instead.

5

solved What is the point of the sep=”” at the end?