I am having a list as :
>>> l = ['1', '2', '3', '4']
if I use join statement,
>>> s = ', '.join(l)
will give me output as :
'1, 2, 3, 4'
But, what I have to do If I want output as :
'1, 2, 3, 4,'
(I know that I can use string concat but I want to know some better way)
.
String concatenation is the best way:
but you have other options also:
Mapping to comma-ended strings, then joining:
Appending empty string to the joined list (don’t modify original
llist!):Using string formatting in place of concatenation: