Python End Parameter
Website Visitors:Python End parameter
In Python, the end
parameter is an optional parameter used with the print()
function. It specifies the string that will be printed at the end of the output. By default, the end
parameter is set to '\n'
, which means that a newline character will be printed at the end of the output.
Here’s an example to illustrate its usage:
|
|
Output:
|
|
In the example above, by setting end=" "
for the first print()
statement, we specify that a space character should be printed at the end instead of the default newline character. Similarly, for the second print()
statement, we set end="!"
to print an exclamation mark instead of a newline character. As a result, the output is displayed on the same line with a space between the words and an exclamation mark at the end.
Run the above python code in your terminal and check the output to understand end parameter better.
Suggested Article
If you’d like to continue reading, checkout our other articles on python here or browse all other topics here.
Conclusion
In conclusion, the end
parameter in Python is used with the print()
function to specify the string that will be printed at the end of the output. By default, the end
parameter is set to '\n'
, which prints a newline character at the end. However, you can customize the ending by assigning a different string to the end
parameter. This allows you to control how the output is displayed, whether it’s on the same line, separated by a specific character, or with no newline character at all.
Your inbox needs more DevOps articles.
Subscribe to get our latest content by email.