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
Although @Burhan Khalid's answer is good, I think it's more understandable like this:
from str import join sentence = ['this','is','a','sentence'] join(sentence, "-")
The second argument to join() is optional and defaults to " ".
EDIT: This function was removed in Python 3