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)
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)
All Python Examples are in Python 3, so Maybe its different from python 2 or upgraded versions.
Degree in Computer Science and Engineer: App Developer and has multiple Programming languages experience. Enthusiasm for technology & like learning technical.