Python String Operations
There are many operations that can be performed with string which makes it one of the most used datatypes in Python.
Concatenation of Two or More Strings
Joining of two or more strings into a single one is called concatenation.
The + operator does this in Python. Simply writing two string literals together also concatenates them.
The * operator can be used to repeat the string for a given number of times.
str1 = ‘Hello’
str2 =’World!’
# using +
print(str1 + str2)
Output:
HelloWorld!
# using *
print(str1 * 3)
output:
HelloHelloHello