Google News
logo
Python - Interview Questions
What is the purpose of “end” in Python?
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.
 
# Example: Print a  instead of the new line in the end.
print("Let's learn" , end = ' ')  
print("Python") 

# Printing a dot in the end.
print("Learn to code from freetimelearn" , end = '.')  
print("com", end = ' ')
 
Output :
Let's learn Python
Learn to code from freetimelearn.com
Advertisement