Question

I apologize in advance if this question has already been asked and answered, but I cannot find an answer. I do not know the technical term for it so I will write the desired input and output. Basically I have a list of strings, each string containing a word. How would I make it so that the words just appear as they are, rather than a list of strings:

I have:

['hello','my','name','is','david']

But need:

hello my name is david

The purpose of this code is to write

hello my name is david

to a file, but i'm confident I can do that part myself.

If this has already been answered a link to the question would be great, thanks.

Was it helpful?

Solution

You would join them together:

words = ['hello','my','name','is','david']
sentence = ' '.join(words)
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top