Given a string, and we have to append more string (text) at the end of the string using += operator in Python.
There are two methods to add string (text) at the end of the string:
- String.append() Method
- By using += operator
Example:
Input:
str: 'New Delhi'
Concatenation of more text
str += ' ' #space
str += 'Chennai'
str += ' ' #space
str += 'Mumbai'
str += ' ' #space
str += 'Bangalore'
Output:
str: 'New Delhi Chennai Mumbai Bangalore'
Program:
Output
need an explanation for this answer? contact us directly to get an explanation for this answer