A concatenation is the joining of two or more strings into one sitting. In Python, we use the + operators to achieve this. When you write two string literals together, it also concatenates them. We use the * operator to repeat the strings a particular number of times.
str1 = ‘Hello’ str2 = ‘World’ # using + print (str1 + str2 = ‘, str1 + str2) # using * print (str1 * 3 = ‘, str1 * 3)
When you write two string literals, this also concatenates them just like the + operator. You can also use parentheses if you want to proceed to concatenate strings in separate lines.
>>> # two string literals together >>> ‘Hello “World!’ ‘Hello World!’ >>> # using parentheses >>> s = (‘Hello’…’World’) >>> s ‘Hello World’