Using the print function

suggest change

In Python 3, print functionality is in the form of a function:

print("This string will be displayed in the output")
# This string will be displayed in the output

print("You can print \n escape characters too.")
# You can print escape characters too.

In Python 2, print was originally a statement, as shown below.

print "This string will be displayed in the output"
# This string will be displayed in the output

print "You can print \n escape characters too."
# You can print escape characters too.

Note: using from __future__ import print_function in Python 2 will allow users to use the print() function the same as Python 3 code. This is only available in Python 2.6 and above.

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:



Table Of Contents