In this Python tutorial, we will study Python String Concatenation with example. Strings are very useful in any programming language, so in Python Programming too. Below we will see how to concatenate two or more Strings in Python.
In Python, Strings can be concatenate with Plus sign +. Let’s see below Python String Concatenation example
#Python String concatenation Example str1="Python tutorial " str2="for beginners" str3=str1+str2 print(str3)
Python tutorial for beginners
str2are two String when we concatenate str1 and str2 with plus + sign, these strings will merge into one and we store that String into str3.
- String str3 will also be a String, you can check this by using type() function of Python. when you will write
print(type(str3))result will be
we can only concatenate Strings using plus operator. If we concatenate String with Integer using plus, It will throw error.
#Python String concatenation Example str1="Python tutorial " num1=1 str3=str1+num1 print(str3) print(type(str3))
TypeError: must be str, not int
So, In this Python example series, we study that how two strings in Python can be concatenated.