Is there a simpler way to concatenate string items in a list into a single string? Can I use the str.join() function?
str.join()
E.g. this is the input [\'t
[\'t
We can also use Python's reduce function:
from functools import reduce sentence = ['this','is','a','sentence'] out_str = str(reduce(lambda x,y: x+"-"+y, sentence)) print(out_str)