Append a string in Python
To append a string value to a string variable in Python, you can use String Addition Assignment Operator. Pass this string variable as left operand, and the other string or another string variable as right operand. The operator appends the other string to the value in this string variable.
thisString += otherString
1. Append “banana” to value in variable x
In the following program, we take a string value in x. We then use String Addition Assignment operator to append "banana" to the string in x.
2. Append string value in y to value in variable x
In the following program, we take two string values in x, y. We then use String Addition Assignment operator to append the string value in variable y to that of in x.
In this tutorial of Python Examples, we learned how to append another string to the end of this string using String Addition Assignment Operator, with the help of well detailed examples.