How to concatenate strings in Python?
By Lenin Mishra
If you prefer to watch Youtube videos over reading blogs, check out our video on Python strings here.
Concatenating strings in Python
Concatenation is joining of two or more strings into a single string.
In Python, the +
operator is used for concatenation.
You can also concatenate two strings by writing them together.
Another way is to use the *
operator to repeat the string for a given number of times.
Code
str1 = "I like "
str2 = "Pylenin"
print(str1+str2)
print(str1, str2)
print(str1*2)
Output
I like Pylenin
I like Pylenin
I like I like
Related Articles
- How to create a string in Python?
- How to access characters in a Python string?
- How to replace characters in a string in Python?
- How to iterate through a string in Python?
- Check if a Substring is Present in a Given String in Python
- Escape sequences in Python String
- Python String Formatting - The Definitive Guide
- Commonly used Python string methods