Difference between end and sep in Python Last Updated : 27 Sep, 2023 Summarize Comments Improve Suggest changes Share Like Article Like Report 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. end in PythonThe end is a parameter in Python's built-in print() function that controls what character(s) are printed at the end of the printed text. The end is set to \n (newline character) which means that each call to print() will print the output on a new line. we can change the value of the end to print a different character or string at the end of the printed text.Syntax : print(*objects, sep=' ', end='\n', file=sys.stdout, flush=False) Example : Python for i in range(1, 6): print i, Output : 1 2 3 4 5sep 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-cherryHere's an example that represents both the sep and end parameters in one lineExample : Python3 print("Apples", "Orange", "Mango", sep=", ", end=" are fruits!\n") Output: Apples, Orange, Mango are fruits!Difference Between end and sep in Python ParameterFunctionDefault Value Usage Example end Specifies what should be printed at the end of the output. '\n' (newline character) print("Hello", end='!')<br>Prints "Hello!" with an exclamation mark at the end. sep Specifies what separator character should be printed between multiple values. Space character (' ') print("apple", "banana", "cherry", sep='-')<br>Prints "apple-banana-cherry" with hyphens between each value. Conclusion In Python, the sep parameter controls how items are separated within single print() statement in while the end parameter determines what is printed at the end of statement. These parameters provide flexibility in the formatting output according to your specific requirements. Comment More infoAdvertise with us Next Article Difference between append() and extend() in Python S subramanyasmgm Follow Improve Article Tags : Python Geeks Premier League Geeks Premier League 2023 Practice Tags : python Similar Reads Difference between return and print in Python In Python, we may use the print statements to display the final output of a code on the console, whereas the return statement returns a final value of a function execution which may be used further in the code. In this article, we will learn about Python return and print statements. Return Statement 2 min read Difference between append() and extend() in Python extend() and append() are two Python list methods used to add elements to a list but they behave quite differently. The append() adds a single item or any object, while extend() adds each element of an iterable to the list. In this article, weâll explore the differences between append() and extend() 2 min read Difference Between strip and split in Python The major difference between strip and split method is that strip method removes specified characters from both ends of a string. By default it removes whitespace and returns a single modified string. Whereas, split method divides a string into parts based on a specified delimiter and by default it 1 min read Difference between %s and %d in Python string In this article, we will see the difference between %s and %d in Python. Here, we start with the proper explanation of one at a time, then both, and at last compare these. What does %s do in Python? The % symbol is used in Python with a large variety of data types and configurations. It is used as a 3 min read Difference between / vs. // operator in Python In Python, both / and // are used for division, but they behave quite differently. Let's dive into what they do and how they differ with simple examples./ Operator (True Division)The / operator performs true division.It always returns a floating-point number (even if the result is a whole number).It 2 min read Difference Between Del, Remove and Pop in Python Lists del is a keyword and remove(), and pop() are in-built methods in Python. The purpose of these three is the same but the behavior is different. remove() method deletes values or objects from the list using value and del and pop() deletes values or objects from the list using an index.del Statementdel 2 min read Like