Print function

In Python, the print function prints things to the screen. In its simplest form it has the following syntax


More than one argument can be passed to print at a time. By default, multiple arguments are printed on the same line with a space inserted between each one and at the end of each print statement Python will insert a new line, so subsequent calls to print will output on consecutive lines. These default behaviors can be overridden, see the Python 3.2 Documentation for details.

If the arguments aren't already strings, print will convert them to strings just as str would.

By way of example, the following are some sample print statements, and their output

>>> print(5)
>>> print('this is a test')
this is a test
>>> print('this','is','another','test') # note that spaces are inserted
this is another test
>>> print('this'+'is'+'another'+'test') # no spaces are automatically inserted, because there is only one argument
>>> print('The Answer is', 42)
The Answer is 42

See Also

Python 3.2 Documentation

Invalid username
Login to AoPS