Join string before, between, and after

python, string

Solution

>>> '{1}{0}{1}'.format(s.join(lis), s)
'xaxbxcxdx'

Problem

Suppose I have this list: ``` lis = ['a','b','c','d'] ``` If I do `'x'.join(lis)` the result is: ``` 'axbxcxd' ``` What would be a clean, simple way to get this output? ``` 'xaxbxcxdx' ``` I could write a helper function: ``` def joiner(s, it): return s+s.join(it)+s ``` and call it like `joiner('x',lis)` which returns `xaxbxcxdx`, but it doesn't look as clean as it could be. Is there a better way to get this result?

Original source