sep in Python
the sep parameter is used to specify the separator between the values that are passed to the print() function.
- The print() uses a space character as the separator between values.
Syntax :
print(value1, value2, …, sep=’separator’)
Example :
Python
print ( "apple" + "-" + "banana" + "-" + "cherry" ) |
Output :
apple-banana-cherry
Here’s an example that represents both the sep and end parameters in one line
Example :
Python3
print ( "Apples" , "Orange" , "Mango" , sep = ", " , end = " are fruits!\n" ) |
Output:
Apples, Orange, Mango are fruits!
Difference between end and sep in Python
In this article we will discuss the difference between The end and sep are two parameters in Python’s built-in print() function that will help to control how the output is formatted.
Contact Us