I have a list with string elements: lst = ['h', 'e', 'l', 'l', 'o']
, and I want to convert it to a single element list but split by ,
.
The expected list will like this:
['h, e, l, l, o']
How could I do that?
CodePudding user response:
You could use a string join:
lst = ['h', 'e', 'l', 'l', 'o']
output = [', '.join(lst)]
print(output) # ['h, e, l, l, o']