Python – Concatenate Strings

Concatenate Strings

Concatenation is the process of joining two or more items into a single. Concatenation of strings is the joining of two or more strings into a single string.

To concatenate two or more strings in Python, we can use Addition Operator + . The operator can take two strings as operands, concatenates the string, and returns the resulting string string.

Syntax

The syntax of the expression to check concatenate the strings str1 and str2 using Addition Operator is

str1 + str2
Run

We can concatenate more than two strings in a single expression as shown in the following.

str1 + str2 + str3 + str4
Run

Examples

1. Concatenate two strings

In the following program, we take two string in str1 and str2 variables, and concatenate them using Addition Operator.

Python Program

str1 = 'apple'
str2 = 'banana'

output = str1 + str2

print(output)
Run

Output

applebanana

2. Concatenate more than two strings

In the following program, we take three string values in str1, str2, and str3 variables, and concatenate them into output, and print the resulting string to console.

Python Program

str1 = 'apple'
str2 = 'banana'
str3 = 'cherry'

output = str1 + str2 + str3

print(output)
Run

Output

applebananacherry

Summary

In this tutorial of Python Examples, we learned how to concatenate two or more strings using Addition operator, with the help of well detailed examples.