Python - Output Variables
Python - Output Variables
❮ PreviousNext ❯
Output Variables
The Python print() function is often used to output variables.
Example
x = "Python"
y = "is"
z = "awesome"
print(x, y, z)
Try it Yourself »
Example
x = "Python "
y = "is "
z = "awesome"
print(x + y + z)
Try it Yourself »
Notice the space character after "Python " and "is ", without them the result
would be "Pythonisawesome".
Example
x = 5
y = 10
print(x + y)
Try it Yourself »
In the print() function, when you try to combine a string and a number with
the + operator, Python will give you an error:
Example
x = 5
y = "John"
print(x + y)
Try it Yourself »
The best way to output multiple variables in the print() function is to separate
them with commas, which even support different data types:
Example
x = 5
y = "John"
print(x, y)