Python Tutorials · Python Variables

Output Variables

Learn all about Output Variables in this comprehensive tutorial.

5 min read beginner
  • The print() function is often used to output variables.

Output Variables

The print() function is often used to output variables.

python

In the print() function, you output multiple variables, separated by a comma:

python

You can also use the + operator to output multiple variables:

python
Note: Notice the space character after "Python " and "is ", without them the result would be "Pythonisawesome".

For numbers, the + character works as a mathematical operator:

python

In the print() function, when you try to combine a string and a number with the + operator, Python will give you an error:

python

The best way to output multiple variables in the print() function is to separate them with commas, which even support different data types:

python