In Python, the end parameter in the print() function is used to specify the string that should be printed after the last argument of the function. By default, the end parameter is set to "\n", which means that a newline character is printed after the output. This results in the next output being printed on the next line.
However, we can change the end parameter to any other string that we want to be printed after the last argument of the print() function. For example, setting end=" " will print a space character after the last argument, instead of a newline character. This will cause the next print() function to print its output on the same line as the previous one.
Here's an example to illustrate the use of end=" ":
print("Hello", end=" ") print("world!")
In this example, the end=" " parameter is used to print a space character after the first string "Hello". This causes the second print() function to start printing on the same line, resulting in the output "Hello world!".
We can also use other characters or strings as the end parameter. For example, setting end="-" will print a dash character after the last argument, like this:
print("one", "two", "three", end="-") print("four")
Output:
one two three-four
In this example, the end="-" parameter is used to print a dash character after the last argument of the first print() function. This causes the second print() function to start printing on the same line, with the output "four" being printed after the dash.
In summary, the end parameter in the print() function is used to specify the string that should be printed after the last argument. By default, this is a newline character, but we can change it to any other character or string that we want to be printed.
.png)
Comments
Post a Comment