Python String Concatenation
String Concatenation
String concatenation means add strings together.
Use the + character to add a variable to another variable:
Example
Merge variable a with variable
b into variable c:
a = "Hello"
b = "World"
c = a + b
print(c)
Try it Yourself »
b = "World"
c = a + b
print(c)
Example
To add a space between them, add a " ":
a = "Hello"
b = "World"
c = a + " " + b
print(c)
Try it Yourself »
b = "World"
c = a + " " + b
print(c)
For numbers, the + character works as a mathematical operator:
If you try to combine a string and a number, Python will give you an error:
Related Pages
Python Variables Tutorial Creating Variables Variable Names Assign Value to Multiple Variables Output Variables Global Variables