+ 2
How the sep and end is used in python print function?
2 Réponses
+ 7
Let's say you want to print 1-2-3-4@.
You can easily do this using sep and end:
print(1, 2, 3, 4, sep="-", end="@")
+ 3
The default for sep is ' ' and the default for end is '\n' (newline).
That's why every print starts in a new line and when you print several variables or something, they are separated by a space.
Now by changing sep and end, you can arbitrarily change that behaviour to something else as Diego demonstrated.