Python – Concatenate Strings

Concatenate Strings in Python

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

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

str1 + str2 + str3 + str4

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 Code Copy

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 Code Copy

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.

Related Tutorials

Code copied to clipboard successfully 👍