Python String Concatenation

Learn how to concatenate, or combine, two strings in Python using the + operator. Check out the example to see how to merge two variables and print the result.



String Concatenation

To concatenate, or combine, two strings, you can use the + operator.

Example

Merge variable a with variable b into variable c:


a = "Hello"
b = "World"
c = a + b
print(c)
      
Output

HelloWorld
      
Example

To add a space between the two strings, include a space in the concatenation:


a = "Hello"
b = "World"
c = a + " " + b
print(c)
      
Output

Hello World