I’m learning Python. I’d like to do the following task:
- Input: a list: e.g.,
['a', 'b', 'c'] - Output: a single string that concatenate all elements in the list, while each element is modifed in the same way for all elements.
For example, I’d like to add "-temp" to each element in the list. So, the output would be:
"a-temp b-temp c-temp"
Of couse, I can write C/C++ style. But, is there more elegant or interesting way in Python?
1 Answer