Print Text
The print() function shows text or other values on the screen. Unless you tell it otherwise, every call starts on a new line.
Example
Prompt
Print "Hello World!" to the screen.
Output: complete Python program
main.py
print("Hello World!")
Multiple prints
There is no limit on how many times you can call print():
Prompt
Print three lines: "Hello World!", "I am learning Python.", and "It is awesome!" using separate print statements.
Output: complete Python program
main.py
print("Hello World!")
print("I am learning Python.")
print("It is awesome!")
Double Quotes
Python expects text to be wrapped in quotes, and either " double or ' single quotes will do. Text without quotes causes an error.
Both quote types
Prompt
Print two lines: one using double quotes and one using single quotes, showing both work the same way.
Output: complete Python program
main.py
print("This will work!")
print('This will also work!')
Missing quotes error
Here the quotes around the text are missing, so Python reports an error:
Prompt
Demonstrate a syntax error by trying to print text without quotes.
Output: complete Python program
main.py
print(This will cause an error)
Print Without a New Line
Normally, print() finishes by moving to a new line. Set its end parameter when you want several pieces of text to stay on one line.
Example
Prompt
Use the end parameter to print two messages on the same line, with a space between them.
Output: complete Python program
main.py
print("Hello World!", end=" ")
print("I will print on the same line.")