Skip to content

Concatenation Operator in Python

  • by

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

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

Note: Both single quotes and double quotes 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


Concatenation Operator in Python

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

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

Python String Concatenation in the print function.

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

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 *