Python’s print() function always prints a newline in the end. The print() function accepts an optional parameter known as the ‘end.’ Its value is ‘\n’ by default. We can change the end character in a print statement with the value of our choice using this parameter.
Let us see an example code, in which I am using the end with the print function.
# This Python program must be run with
# Python 3 as it won't work with 2.7.
# Example: Print a space instead of the new line in the end.
print("Let's learn" , end = ' ')
print("Python")
# Printing a dot in the end.
print("Learn programming from aticleworld" , end = '.')
print("com", end = ' ')
Output:
Let’s learn Python Learn programming from aticleworld.com
Answer:
Python’s print() function always prints a newline in the end. The print() function accepts an optional parameter known as the ‘end.’ Its value is ‘\n’ by default. We can change the end character in a print statement with the value of our choice using this parameter.
Let us see an example code, in which I am using the end with the print function.
Output:
Let’s learn Python
need an explanation for this answer? contact us directly to get an explanation for this answerLearn programming from aticleworld.com