What is Python End Parameter?

Learn via video course
FREE
View all courses
Python Course for Beginners With Certification: Mastering the Essentials
Python Course for Beginners With Certification: Mastering the Essentials
by Rahul Janghu
1000
4.90
Start Learning
Python Course for Beginners With Certification: Mastering the Essentials
Python Course for Beginners With Certification: Mastering the Essentials
by Rahul Janghu
1000
4.90
Start Learning
Topics Covered

What is Python End Parameter?

For the addition of any string at the end of the python print statement output, we use the python end Parameter. The print function in python by default ends with a new line. If the whitespace is passed to the end Parameter (end=' ') then it shows that not the new line but the whitespace will be used to identify the end character. There is always a creation of a newline by the print() function of python. Instead of newline we can also add some other characters at the end of the print statement by using end in python.

Syntax:

Examples of Python End Parameter

Without Changing End Parameter Values

If we will not change the python end parameter then the new line character \n is automatically added at the end of the output of the print statement. So next print() statement will be printed from the new line.

Example

Output

Using White-Space in Place of the end Parameter Value

If we are using white space as the python end parameter value, the white space is added at the end of the output of the print statement. In the below example, we are simply passing white-space as the end python parameter. So white-space is added after the string or print() and next print statement will be continued from the current line. Example:

Output

Changing Python End Default Value

We can also write any string in double or single quotes as the python end parameter value, and then that string will be added at the end of the output of the print statement. And newline character is not added in the end of print statement output. So next print statement will also be printed in the continuation of end parameter value. Example:

Output:

FAQs

Q: Can "end" be defined as a keyword or identifier?

A: The "end " is only a parameter for the print() in python. We cannot define the end as a keyword or identifier. So end python can only be used with print().

Q: What values are accepted by the "end" parameter in Python?

A: The values in the form of valid strings are accepted by the end parameter. Single or double quotation marks are used for the representation of strings. Newline character \n will be considered as the default value of end python.

Q: Previous versions of python accept the "end" parameter or not?

A: "End" parameter in the introduced 3.0 version of the python. So the end parameter is not valid in the versions that are earlier from python 3.0.

Q: Is there any alternative available for the "end" parameter in python?

A: End Parameter is used to add a string at the end of a print() but the addition of a string to another string can also be done by the concatenation operator which is represented by the + operator.

Q: Explain the difference between python "sep" and python "end"?

A: Python end Parameter is used for the addition of any string at the end of the output of print(). On the other hand, for the separation of output by character or string in place of default space value, we use the python sep parameter.

Conclusion

  • Python end is used for the addition of any string at the end of the output of the python print statement.
  • By default newline character is added by the python print().
  • White space can also be used as the end python parameter value.
  • We can also use any string as a python end parameter value.
  • End python is introduced in python 3.0.