Skip to content

Concatenation Operator in Python

  • by

Python Concatenation Operator is used to join the two different strings (or other types of data) together. The + symbol is used as concatenation operator in python.

s1 = "Hello"
s2 = "World"
print(s1 + s2)

Note : Both single quote or double quote can be used in python to denote string.

Concatenation Operator in Python

Simple example code if we have below strings that are assigned to the below variables:

x = "Hello"
y = "Python"
z = "World"

res = x + y + z
print(res)

Output:

Concatenation Operator in Python

If you would like to add a space between them then add space string between them.

x = "Hello"
y = "Python"
z = "World"
a = x + " " + y + " " + z
print(a)

Python String Concatenation in print function.

print ("Hello" + "Python" + "World")
print ("Hello" + " " + "Python"+ " " + "World")

Do comment if you have any doubts or suggestions on this Python operator topic.

Note: IDE: PyCharm 2021.3.3 (Community Edition)

Windows 10

Python 3.10.1

All Python Examples are in Python 3, so Maybe its different from python 2 or upgraded versions.

Leave a Reply

Your email address will not be published. Required fields are marked *