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?
from Join string before, between, and after
No comments:
Post a Comment