Q:

What is the purpose of “end” in Python?

0

What is the purpose of “end” in Python?

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

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.

# 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

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Python Interview Questions and Answers

This question belongs to these collections

Similar questions


need a help?


find thousands of online teachers now
Is the Python platform independent?... >>
<< Does Python have a main()method?...