Q:

Python | Printing different messages by using different variations of print() method

belongs to collection: Python basic programs

0

Python | Printing different messages by using different variations of print() method

All Answers

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

Consider the program:

# it will print new line after the messages
print("Hello")
print("World")

# it will print new line
print()

# it will print new line after printing "Hello"
print("Hello",end="\n")
# it willprint new line after printing "World"
print("World")

# it will print new line 
print()

# it will not print new line after printing "Hello"
# it will print space " "
print("Hello",end=" ")
# it will print new line after printing "World"
print("World")

Output

Hello
World

Hello
World

Hello World

Explanation:

print() prints new line after printing the message by default.

end parameter can be used to specify the end character after printing the message - here in this program, we are using end="\n" and end=" ", first one will print a newline after the message and the second one will print the space after printing the message.

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

total answers (1)

Python basic programs

This question belongs to these collections

Similar questions


need a help?


find thousands of online teachers now
Python program to print given text using a user-de... >>
<< How to print spaces in Python?...